Class: Fluent::Plugin::RedisEnrichmentFilter::Cache::LazyCache

Inherits:
NoCache
  • Object
show all
Defined in:
lib/fluent/plugin/filter_redis_enrichment.rb

Instance Attribute Summary

Attributes inherited from NoCache

#log

Instance Method Summary collapse

Methods inherited from NoCache

#clean

Constructor Details

#initialize(redis:, size: DEFAULT_CACHE_SIZE, ttl: DEFAULT_CACHE_TTL, log: nil) ⇒ LazyCache

Returns a new instance of LazyCache.



209
210
211
# File 'lib/fluent/plugin/filter_redis_enrichment.rb', line 209

def initialize(redis:, size: DEFAULT_CACHE_SIZE, ttl: DEFAULT_CACHE_TTL, log: nil)
  super
end

Instance Method Details

#cacheObject



217
218
219
# File 'lib/fluent/plugin/filter_redis_enrichment.rb', line 217

def cache
  @cache ||= LruRedux::TTL::ThreadSafeCache.new(@size, @ttl)
end

#get(key) ⇒ Object



213
214
215
# File 'lib/fluent/plugin/filter_redis_enrichment.rb', line 213

def get(key)
  cache.getset(key) { @redis.get(key) }
end