Method: FastCache::Cache#initialize

Defined in:
lib/fast_cache/cache.rb

#initialize(max_size, ttl, expire_interval = 100) ⇒ Cache

Initializes the cache.

Parameters:

  • max_size (Integer)

    Maximum number of elements in the cache.

  • ttl (Numeric)

    Maximum time, in seconds, for a value to stay in the cache.

  • expire_interval (Integer) (defaults to: 100)

    Number of cache operations between calls to #expire!.



35
36
37
38
39
40
41
42
# File 'lib/fast_cache/cache.rb', line 35

def initialize(max_size, ttl, expire_interval = 100)
  @max_size = max_size
  @ttl = ttl.to_f
  @expire_interval = expire_interval
  @op_count = 0
  @data = {}
  @expires_at = {}
end