Module: HatiConfig::Cache

Included in:
Setting
Defined in:
lib/hati_config/cache.rb

Overview

Cache module provides functionality for caching and refreshing configurations.

Defined Under Namespace

Modules: NumericConfigurable Classes: BackoffConfig, CacheConfig, MemoryAdapter, RedisAdapter, RefreshConfig

Instance Method Summary collapse

Instance Method Details

#cache { ... } ⇒ Object

Defines caching behavior for configurations.

Examples:

cache do
  adapter :redis, url: "redis://cache.example.com:6379/0"
  ttl 300  # 5 minutes
  stale_while_revalidate true
end

Parameters:

  • adapter (Symbol) —

    The cache adapter to use (:memory, :redis)

  • options (Hash) —

    Options for the cache adapter

Yields:

  • The cache configuration block



43
44
45
46
47
# File 'lib/hati_config/cache.rb', line 43

def cache(&block)
  @cache_config = CacheConfig.new
  @cache_config.instance_eval(&block) if block_given?
  @cache_config
end

#cache_config ⇒ CacheConfig

Gets the cache configuration.

Returns:



52
53
54
# File 'lib/hati_config/cache.rb', line 52

def cache_config
  @cache_config ||= CacheConfig.new
end