Class: Coradoc::Configurable::CacheConfig

Inherits:
ConfigSection show all
Defined in:
lib/coradoc/configurable.rb

Overview

Cache configuration section

Instance Attribute Summary collapse

Attributes inherited from ConfigSection

#options

Instance Method Summary collapse

Methods inherited from ConfigSection

#[], #[]=, #merge!, symbolize_keys, #to_h

Constructor Details

#initialize(options = {}) ⇒ CacheConfig

Returns a new instance of CacheConfig.



120
121
122
123
124
125
126
127
# File 'lib/coradoc/configurable.rb', line 120

def initialize(options = {})
  super
  @enabled = @options.fetch(:enabled, true)
  @max_size = @options.fetch(:max_size, 1000)
  @ttl = @options.fetch(:ttl, 0)
  @backend = @options.fetch(:backend, :memory)
  @cache_dir = @options.fetch(:cache_dir, nil)
end

Instance Attribute Details

#backendSymbol

Returns Cache storage backend (:memory, :file, :redis).

Returns:

  • (Symbol)

    Cache storage backend (:memory, :file, :redis)



115
116
117
# File 'lib/coradoc/configurable.rb', line 115

def backend
  @backend
end

#cache_dirString?

Returns Cache directory for file backend.

Returns:

  • (String, nil)

    Cache directory for file backend



118
119
120
# File 'lib/coradoc/configurable.rb', line 118

def cache_dir
  @cache_dir
end

#enabledBoolean

Returns Whether caching is enabled.

Returns:

  • (Boolean)

    Whether caching is enabled



106
107
108
# File 'lib/coradoc/configurable.rb', line 106

def enabled
  @enabled
end

#max_sizeInteger

Returns Maximum cache size (number of entries).

Returns:

  • (Integer)

    Maximum cache size (number of entries)



109
110
111
# File 'lib/coradoc/configurable.rb', line 109

def max_size
  @max_size
end

#ttlInteger

Returns Cache TTL in seconds (0 = no expiry).

Returns:

  • (Integer)

    Cache TTL in seconds (0 = no expiry)



112
113
114
# File 'lib/coradoc/configurable.rb', line 112

def ttl
  @ttl
end