Cache.Redis (elixir_cache v0.3.9)

View Source

Redis adapter for distributed caching with ElixirCache.

This adapter provides a connection pool to Redis, enabling distributed caching across multiple nodes or services. It supports the standard Cache behavior plus additional Redis-specific operations like hash manipulation, JSON operations, and sets.

Features

  • Connection pooling for efficient Redis access
  • Support for Redis URI connection strings
  • Hash operations for storing field-value pairs within a key
  • JSON operations for working with complex nested data structures
  • Set operations for managing collections
  • Direct access to Redis commands via pipeline and command functions

Options

  • :uri (String.t/0) - Required. The connection uri to redis

  • :size (pos_integer/0) - The amount of workers in the pool

  • :max_overflow (pos_integer/0) - The amount of max overflow the pool can handle

  • :strategy - The type of queue to use for poolboy

Example

defmodule MyApp.RedisCache do
  use Cache,
    adapter: Cache.Redis,
    name: :my_app_redis_cache,
    opts: [
      uri: "redis://localhost:6379",
      size: 10,
      max_overflow: 5
    ]
end

Summary

Functions

See Cache.Redis.Global.command/3.

See Cache.Redis.Global.command!/3.

See Cache.Redis.Hash.hash_delete/4.

See Cache.Redis.Hash.hash_get/4.

See Cache.Redis.Hash.hash_get_all/3.

See Cache.Redis.Hash.hash_get_many/3.

See Cache.Redis.Hash.hash_scan/4.

See Cache.Redis.Hash.hash_values/3.

See Cache.Redis.JSON.clear/4.

See Cache.Redis.JSON.delete/4.

See Cache.Redis.JSON.get/4.

See Cache.Redis.Global.pipeline/3.

See Cache.Redis.Global.pipeline!/3.

See Cache.Redis.Set.sadd/4.

See Cache.Redis.Global.scan/3.

See Cache.Redis.Set.smembers/3.

Functions

command(pool_name, command, opts \\ [])

See Cache.Redis.Global.command/3.

command!(pool_name, command, opts \\ [])

See Cache.Redis.Global.command!/3.

hash_delete(pool_name, key, field, opts \\ [])

See Cache.Redis.Hash.hash_delete/4.

hash_get(pool_name, key, field, opts \\ [])

See Cache.Redis.Hash.hash_get/4.

hash_get_all(pool_name, key, opts \\ [])

See Cache.Redis.Hash.hash_get_all/3.

hash_get_many(pool_name, key_fields, opts \\ [])

See Cache.Redis.Hash.hash_get_many/3.

hash_scan(pool_name, key, scan_opts, opts \\ [])

See Cache.Redis.Hash.hash_scan/4.

hash_set(pool_name, key, field, value, ttl, opts \\ [])

See Cache.Redis.Hash.hash_set/6.

hash_set_many(pool_name, keys_fields_values, ttl, opts \\ [])

See Cache.Redis.Hash.hash_set_many/4.

hash_values(pool_name, key, opts \\ [])

See Cache.Redis.Hash.hash_values/3.

json_array_append(pool_name, key, path, value_or_values, opts \\ [])

See Cache.Redis.JSON.array_append/5.

json_clear(pool_name, key, path, opts \\ [])

See Cache.Redis.JSON.clear/4.

json_delete(pool_name, key, path, opts \\ [])

See Cache.Redis.JSON.delete/4.

json_get(pool_name, key, path, opts \\ [])

See Cache.Redis.JSON.get/4.

json_incr(pool_name, key, path, value \\ 1, opts \\ [])

See Cache.Redis.JSON.incr/5.

json_set(pool_name, key, path, value, opts \\ [])

See Cache.Redis.JSON.set/5.

ms_to_nearest_sec(ms)

pipeline(pool_name, command, opts \\ [])

See Cache.Redis.Global.pipeline/3.

pipeline!(pool_name, command, opts \\ [])

See Cache.Redis.Global.pipeline!/3.

pool_config(pool_name, opts)

sadd(pool_name, key, value, opts)

See Cache.Redis.Set.sadd/4.

scan(pool_name, scan_opts, opts \\ [])

See Cache.Redis.Global.scan/3.

smembers(pool_name, key, opts)

See Cache.Redis.Set.smembers/3.