Skip to content

MemcachedCacheOptions

Defined in: src/cache/MemcachedCache.ts:28

Memcached-backed Cache — wraps memjs (pure-JS memcached client, tiny, well-maintained). Useful for shops with existing memcached infrastructure; in greenfield setups Redis is the better default (richer primitives, better cluster story).

Wire format:

  • Values are JSON-stringified before send and parsed on receive.
  • TTLs are passed as seconds (memcached’s native unit) — the interface uses milliseconds, we round up to the nearest second internally with a 1s minimum.
  • incr uses memcached’s atomic INCR with a CAS-based create fallback for the first-key-write (memcached’s incr doesn’t auto-create like Redis does).
  • setIfAbsent maps to memcached’s add operation.

Failure model matches RedisCache: get/set/delete swallow transient errors; incr and setIfAbsent propagate so callers can detect lost atomicity.

readonly optional client?: MemcachedClientLike

Defined in: src/cache/MemcachedCache.ts:37

Pre-built memjs client — bypass internal construction.


readonly optional keyPrefix?: string

Defined in: src/cache/MemcachedCache.ts:35

Optional key prefix (server-side, applied to every operation).


readonly optional password?: string

Defined in: src/cache/MemcachedCache.ts:33


readonly optional servers?: string

Defined in: src/cache/MemcachedCache.ts:30

Comma-separated server list, e.g. 'localhost:11211'. Default: 'localhost:11211'.


readonly optional username?: string

Defined in: src/cache/MemcachedCache.ts:32

Optional username/password for SASL auth.