Skip to content

Redis

Redis is an in-memory data structure store used as a database, cache, and message broker. Hyperterse provides support for Redis, enabling you to execute Redis commands for key-value operations, caching, session storage, rate limiting, and working with Redis data structures like hashes, lists, sets, and sorted sets.

Redis adapters use the standard Redis URI format:

adapters:
my_redis:
connector: redis
connection_string: 'redis://localhost:6379/0'

Configure connection pooling and other settings:

adapters:
cache:
connector: redis
connection_string: 'redis://localhost:6379/0'
options:
pool_size: 10

For connection string format and authentication options, see the Redis connection documentation.

It is very easy to set up a database for Hyperterse. You can use your existing database or create a new one and wire it up to Hyperterse.

  1. Start Redis

    Start Redis using your preferred method:

    Terminal window
    # Docker
    docker run -d -p 6379:6379 redis:latest
    # macOS with Homebrew
    brew services start redis
    # Linux (systemd)
    sudo systemctl start redis
    # Or run directly
    redis-server
  2. Configure Hyperterse

    Add the Redis adapter to your configuration:

    adapters:
    cache:
    connector: redis
    connection_string: 'redis://localhost:6379/0'
    options:
    pool_size: 10

    For password-protected Redis instances:

    connection_string: 'redis://:password@localhost:6379/0'

    For TLS-enabled Redis (cloud providers):

    connection_string: 'rediss://:password@host:6379/0'
  3. Verify connection

    Test the connection using the development server:

    Terminal window
    hyperterse dev -f config.terse

    Look for a successful connection message:

    INFO Connected to adapter: cache

Redis queries in Hyperterse execute Redis commands directly. The statement field contains the Redis command to execute:

queries:
get-value:
use: cache
description: 'Get a cached value'
statement: 'GET {{ inputs.key }}'
inputs:
key:
type: string
description: 'Cache key'

Hyperterse supports all standard Redis commands including strings, hashes, lists, sets, sorted sets, and key management operations. Use parameterized inputs for dynamic values in commands. Redis commands return results in JSON format, with multiple values returned as arrays or key-value pairs depending on the command type.

Hyperterse inherently does not limit any performance optimizations. You can optimize your queries and database to whatever degree Redis allows.

Verify Redis is running and accessible:

Terminal window
redis-cli ping

Should return PONG. Check firewall rules and network connectivity for remote Redis instances.

Verify the password in the connection string:

connection_string: 'redis://:correct_password@localhost:6379/0'

Ensure the Redis server has authentication enabled and the password matches.

For cloud Redis providers that require TLS, use rediss:// protocol:

connection_string: 'rediss://:password@host:6379/0'

Note the double s in rediss:// for secure connections.

Monitor Redis memory usage and set appropriate expiration times for keys. Use INFO memory command to check memory statistics and configure maxmemory policy if needed.