Liking cljdoc? Tell your friends :D

wagoe.cache.ports

Port definitions for distributed caching.

This module defines protocols for distributed caching, providing a unified interface for different cache backends (Redis, Memcached, in-memory).

Key Features:

  • Get/Set/Delete operations with TTL
  • Batch operations for performance
  • Atomic operations (increment/decrement)
  • Pattern-based operations (keys, delete by pattern)
  • Namespace support for multi-tenancy
  • Cache statistics and monitoring
Port definitions for distributed caching.

This module defines protocols for distributed caching, providing a
unified interface for different cache backends (Redis, Memcached, in-memory).

Key Features:
- Get/Set/Delete operations with TTL
- Batch operations for performance
- Atomic operations (increment/decrement)
- Pattern-based operations (keys, delete by pattern)
- Namespace support for multi-tenancy
- Cache statistics and monitoring
raw docstring

IAtomicCachecljprotocol

Protocol for atomic cache operations.

Protocol for atomic cache operations.

compare-and-swap!clj

(compare-and-swap! this key expected-value new-value)

Atomically set value only if current value equals expected value (CAS).

Args: key - Cache key expected-value - Value to compare against current value new-value - Value to set if comparison succeeds

Returns: true if value was updated, false if current value didn't match expected

Atomically set value only if current value equals expected value (CAS).

Args:
  key - Cache key
  expected-value - Value to compare against current value
  new-value - Value to set if comparison succeeds

Returns:
  true if value was updated, false if current value didn't match expected

decrement!clj

(decrement! this key)
(decrement! this key delta)

Atomically decrement numeric value.

Args: key - Cache key delta - Amount to decrement (default 1)

Returns: New value after decrement

Atomically decrement numeric value.

Args:
  key - Cache key
  delta - Amount to decrement (default 1)

Returns:
  New value after decrement

increment!clj

(increment! this key)
(increment! this key delta)

Atomically increment numeric value.

Args: key - Cache key delta - Amount to increment (default 1)

Returns: New value after increment

Atomically increment numeric value.

Args:
  key - Cache key
  delta - Amount to increment (default 1)

Returns:
  New value after increment

set-if-absent!clj

(set-if-absent! this key value)
(set-if-absent! this key value ttl-seconds)

Set value only if key doesn't exist (SETNX).

Args: key - Cache key value - Value to set ttl-seconds - Optional TTL

Returns: true if value was set, false if key already exists

Set value only if key doesn't exist (SETNX).

Args:
  key - Cache key
  value - Value to set
  ttl-seconds - Optional TTL

Returns:
  true if value was set, false if key already exists
sourceraw docstring

IBatchCachecljprotocol

Protocol for batch cache operations.

Protocol for batch cache operations.

delete-many!clj

(delete-many! this keys)

Delete multiple keys at once.

Args: keys - Collection of cache keys

Returns: Number of keys deleted

Delete multiple keys at once.

Args:
  keys - Collection of cache keys

Returns:
  Number of keys deleted

get-manyclj

(get-many this keys)

Get multiple values at once.

Args: keys - Collection of cache keys

Returns: Map of key -> value (missing keys are omitted)

Get multiple values at once.

Args:
  keys - Collection of cache keys

Returns:
  Map of key -> value (missing keys are omitted)

set-many!clj

(set-many! this key-value-map)
(set-many! this key-value-map ttl-seconds)

Set multiple key-value pairs at once.

Args: key-value-map - Map of key -> value ttl-seconds - Optional TTL for all keys

Returns: Number of keys set

Set multiple key-value pairs at once.

Args:
  key-value-map - Map of key -> value
  ttl-seconds - Optional TTL for all keys

Returns:
  Number of keys set
sourceraw docstring

ICachecljprotocol

Protocol for basic cache operations.

Protocol for basic cache operations.

delete-key!clj

(delete-key! this key)

Delete key from cache.

Args: key - Cache key

Returns: true if key was deleted, false if key didn't exist

Delete key from cache.

Args:
  key - Cache key

Returns:
  true if key was deleted, false if key didn't exist

exists?clj

(exists? this key)

Check if key exists in cache.

Args: key - Cache key

Returns: true if key exists, false otherwise

Check if key exists in cache.

Args:
  key - Cache key

Returns:
  true if key exists, false otherwise

expire!clj

(expire! this key ttl-seconds)

Set expiration time for existing key.

Args: key - Cache key ttl-seconds - Time-to-live in seconds

Returns: true if successful

Set expiration time for existing key.

Args:
  key - Cache key
  ttl-seconds - Time-to-live in seconds

Returns:
  true if successful

get-valueclj

(get-value this key)

Get value from cache by key.

Args: key - Cache key (string or keyword)

Returns: Cached value or nil if not found

Get value from cache by key.

Args:
  key - Cache key (string or keyword)

Returns:
  Cached value or nil if not found

set-value!clj

(set-value! this key value)
(set-value! this key value ttl-seconds)

Set value in cache with optional TTL.

Args: key - Cache key (string or keyword) value - Value to cache (must be serializable) ttl-seconds - Time-to-live in seconds (optional)

Returns: true if successful

Set value in cache with optional TTL.

Args:
  key - Cache key (string or keyword)
  value - Value to cache (must be serializable)
  ttl-seconds - Time-to-live in seconds (optional)

Returns:
  true if successful

ttlclj

(ttl this key)

Get remaining TTL for key.

Args: key - Cache key

Returns: Remaining seconds or nil if key doesn't exist or has no expiration

Get remaining TTL for key.

Args:
  key - Cache key

Returns:
  Remaining seconds or nil if key doesn't exist or has no expiration
sourceraw docstring

ICacheManagementcljprotocol

Protocol for cache management operations.

Protocol for cache management operations.

close!clj

(close! this)

Close cache connection and release resources.

Returns: true if successful

Close cache connection and release resources.

Returns:
  true if successful

flush-all!clj

(flush-all! this)

Clear entire cache (use with caution!).

Returns: Number of keys deleted

Clear entire cache (use with caution!).

Returns:
  Number of keys deleted

pingclj

(ping this)

Check cache connection health.

Returns: true if cache is reachable, false otherwise

Check cache connection health.

Returns:
  true if cache is reachable, false otherwise
sourceraw docstring

ICacheStatscljprotocol

Protocol for cache statistics and monitoring.

Protocol for cache statistics and monitoring.

cache-statsclj

(cache-stats this)

Get cache statistics.

Returns: Map with: :size - Number of keys in cache :hits - Cache hit count (if tracked) :misses - Cache miss count (if tracked) :hit-rate - Hit rate percentage (if tracked) :memory-usage - Memory usage in bytes (if available)

Get cache statistics.

Returns:
  Map with:
    :size - Number of keys in cache
    :hits - Cache hit count (if tracked)
    :misses - Cache miss count (if tracked)
    :hit-rate - Hit rate percentage (if tracked)
    :memory-usage - Memory usage in bytes (if available)

clear-stats!clj

(clear-stats! this)

Clear cache statistics.

Returns: true if successful

Clear cache statistics.

Returns:
  true if successful
sourceraw docstring

INamespacedCachecljprotocol

Protocol for namespaced cache operations.

Protocol for namespaced cache operations.

clear-namespace!clj

(clear-namespace! this namespace)

Clear all keys in a namespace.

Args: namespace - Namespace prefix

Returns: Number of keys deleted

Clear all keys in a namespace.

Args:
  namespace - Namespace prefix

Returns:
  Number of keys deleted

with-namespaceclj

(with-namespace this namespace)

Create a namespaced cache view.

Args: namespace - Namespace prefix (e.g., 'user', 'session')

Returns: Cache instance with namespace prefix

Create a namespaced cache view.

Args:
  namespace - Namespace prefix (e.g., 'user', 'session')

Returns:
  Cache instance with namespace prefix
sourceraw docstring

IPatternCachecljprotocol

Protocol for pattern-based cache operations.

Protocol for pattern-based cache operations.

count-matchingclj

(count-matching this pattern)

Count keys matching pattern.

Args: pattern - Pattern string

Returns: Count of matching keys

Count keys matching pattern.

Args:
  pattern - Pattern string

Returns:
  Count of matching keys

delete-matching!clj

(delete-matching! this pattern)

Delete all keys matching pattern.

Args: pattern - Pattern string

Returns: Number of keys deleted

Delete all keys matching pattern.

Args:
  pattern - Pattern string

Returns:
  Number of keys deleted

keys-matchingclj

(keys-matching this pattern)

Get all keys matching pattern.

Args: pattern - Pattern string (e.g., 'user:', 'session:')

Returns: Set of matching keys

Get all keys matching pattern.

Args:
  pattern - Pattern string (e.g., 'user:*', 'session:*')

Returns:
  Set of matching keys
sourceraw docstring

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
Move to previous article
Move to next article
Ctrl+/Jump to the search field
× close