Sockudo
Server

Cache

Caching backends for app lookups, rate limiting, and general key-value storage.

The cache system provides a key-value store with TTL support. It is used internally for rate limiting state and can be used by other subsystems that need fast lookups.

This is the global cache driver configured under cache. The App Manager has its own separate caching layer configured under app_manager.cache.

Drivers

DriverBest ForPersistenceShared Across Nodes
memorySingle-node, developmentNoneNo
redisMulti-node productionYesYes
redis-clusterLarge-scale Redis ClusterYesYes
noneDisable cachingN/AN/A

Set the driver:

CACHE_DRIVER=memory
{ "cache": { "driver": "memory" } }

Memory Cache

In-process cache using Moka, a high-performance concurrent cache.

{
  "cache": {
    "driver": "memory",
    "memory": {
      "ttl": 300,
      "cleanup_interval": 60,
      "max_capacity": 10000
    }
  }
}
SettingDefaultDescription
ttl300Global TTL in seconds (0 = no expiry)
cleanup_interval60Cleanup interval in seconds
max_capacity10000Maximum number of entries

The memory cache is fast but node-local - each Sockudo instance has its own independent cache. This is fine for single-node deployments but means multi-node setups won't share cache state.

Redis Cache

Shared cache using Redis. All Sockudo nodes read from and write to the same Redis instance, ensuring consistency across the cluster.

{
  "cache": {
    "driver": "redis",
    "redis": {
      "prefix": "sockudo_cache:",
      "url_override": null,
      "cluster_mode": false
    }
  }
}
SettingDefaultDescription
prefixsockudo_cache:Redis key prefix
url_overridenullOverride Redis URL (otherwise uses database.redis)
cluster_modefalseUse cluster-aware connections

Redis cache supports per-key TTL via SET EX and additional bulk operations (MGET, MSET).

Redis Cluster Cache

Same as Redis cache but uses Redis Cluster connections. Use this when your Redis infrastructure runs in cluster mode.

{
  "cache": {
    "driver": "redis-cluster",
    "redis": {
      "prefix": "sockudo_cache:",
      "cluster_mode": true
    }
  }
}

Global Cache Tuning

These environment variables adjust cache behavior across multiple subsystems at once:

Env VarDefaultAffects
CACHE_TTL_SECONDS300App manager cache, channel limits, DB caches, memory cache
CACHE_CLEANUP_INTERVAL60MySQL/PostgreSQL caches, memory cache
CACHE_MAX_CAPACITY10000MySQL/PostgreSQL caches, memory cache

Choosing a Driver

ScenarioRecommended Driver
Development / single-nodememory
Multi-node productionredis
Redis Cluster infrastructureredis-cluster
Cache not needednone
When using redis for the adapter, use redis for the cache driver too. The REDIS_URL env var configures all Redis connections at once.
Copyright © 2026