class

ActiveSupport::Cache::RedisCacheStore

v5.2.3 - Show latest stable - Superclass: ActiveSupport::Cache::Store

Redis cache store.

Deployment note: Take care to use a *dedicated Redis cache* rather than pointing this at your existing Redis server. It won’t cope well with mixed usage patterns and it won’t expire cache entries by default.

Redis cache server setup guide: redis.io/topics/lru-cache

  • Supports vanilla Redis, hiredis, and Redis::Distributed.

  • Supports Memcached-like sharding across Redises with Redis::Distributed.

  • Fault tolerant. If the Redis server is unavailable, no exceptions are raised. Cache fetches are all misses and writes are dropped.

  • Local cache. Hot in-memory primary cache within block/middleware scope.

  • read_multi and write_multi support for Redis mget/mset. Use Redis::Distributed 4.0.1+ for distributed mget support.

  • delete_matched support for Redis KEYS globs.

Constants

DEFAULT_ERROR_HANDLER = -> (method:, returning:, exception:) do\nif logger\nlogger.error { "RedisCacheStore: #{method} failed, returned #{returning.inspect}: #{exception.class}: #{exception.message}" }\nend\nend

DEFAULT_REDIS_OPTIONS = {\nconnect_timeout: 20,\nread_timeout: 1,\nwrite_timeout: 1,\nreconnect_attempts: 0,\n}

MAX_KEY_BYTESIZE = 1024

SCAN_BATCH_SIZE = 1000

Attributes

[R]max_key_bytesize
[R]redis_options

Files

  • activesupport/lib/active_support/cache/redis_cache_store.rb