Class: Fluent::Plugin::RedisEnrichmentFilter::RedisPool

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

Overview

proxy for Redis client

allow extract caching of cache

Instance Method Summary collapse

Constructor Details

#initialize(sentinels: DEFAULT_SENTINELS, name: DEFAULT_SENTINEL_MASTER, role: DEFAULT_REDIS_ROLE, host: DEFAULT_REDIS_HOST, port: DEFAULT_REDIS_PORT, db: DEFAULT_REDIS_DB, password: DEFAULT_REDIS_PASSWORD, timeout: DEFAULT_REDIS_TIMEOUT, pool_size: DEFAULT_REDIS_POOL) ⇒ RedisPool

Returns a new instance of RedisPool.



205
206
207
208
209
210
211
212
213
214
215
216
217
# File 'lib/fluent/plugin/filter_redis_enrichment.rb', line 205

def initialize(sentinels: DEFAULT_SENTINELS, name: DEFAULT_SENTINEL_MASTER, role: DEFAULT_REDIS_ROLE,
               host: DEFAULT_REDIS_HOST, port: DEFAULT_REDIS_PORT, db: DEFAULT_REDIS_DB,
               password: DEFAULT_REDIS_PASSWORD, timeout: DEFAULT_REDIS_TIMEOUT, pool_size: DEFAULT_REDIS_POOL)
  @sentinels = sentinels
  @name = name
  @role = role
  @host = host
  @port = port
  @db = db
  @password = password
  @timeout = timeout
  @pool_size = pool_size
end

Instance Method Details

#get(key) ⇒ Object



219
220
221
222
223
224
225
226
227
228
229
230
231
# File 'lib/fluent/plugin/filter_redis_enrichment.rb', line 219

def get(key)
  return if key.nil?

  key_type = redis.type(key)
  case key_type
  when 'none' then nil
  when 'string' then redis.get(key)
  when 'hash' then redis.hgetall(key)
  else
    log.warn("redis key '#{key}' has an unmanaged type '#{key_type}'")
    nil
  end
end

#quitObject



233
234
235
# File 'lib/fluent/plugin/filter_redis_enrichment.rb', line 233

def quit
  redis.quit
end