Ruby on Rails latest stable (v7.1.3.2) - 0 notes - Superclass: ActiveSupport::Cache::Store

Redis Cache Store

Deployment note: Take care to use a dedicated Redis cache rather than pointing this at a persistent Redis server (for example, one used as an Active Job queue). Redis 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

SCAN_BATCH_SIZE = 1000

DEFAULT_ERROR_HANDLER = -> (method:, returning:, exception:) do if logger logger.error { "RedisCacheStore: #{method} failed, returned #{returning.inspect}: #{exception.class}: #{exception.message}" } end ActiveSupport.error_reporter&.report( exception, severity: :warning, source: "redis_cache_store.active_support", ) end

DEFAULT_REDIS_OPTIONS = { connect_timeout: 1, read_timeout: 1, write_timeout: 1, }

MAX_KEY_BYTESIZE = 1024

Attributes

[R] redis
[R] max_key_bytesize
Show files where this class is defined (1 file)
Register or log in to add new notes.