Class: Fluent::Plugin::RedisEnrichmentFilter::RedisPool
- Inherits:
-
Object
- Object
- Fluent::Plugin::RedisEnrichmentFilter::RedisPool
- Defined in:
- lib/fluent/plugin/filter_redis_enrichment.rb
Overview
proxy for Redis client
allow extract caching of cache
Instance Attribute Summary collapse
-
#log ⇒ Object
readonly
Returns the value of attribute log.
Instance Method Summary collapse
- #get(key) ⇒ Object
- #get_all ⇒ Object
-
#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, log: nil) ⇒ RedisPool
constructor
A new instance of RedisPool.
- #quit ⇒ Object
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, log: nil) ⇒ RedisPool
272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 |
# File 'lib/fluent/plugin/filter_redis_enrichment.rb', line 272 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, log: nil) @sentinels = sentinels @name = name @role = role @host = host @port = port @db = db @password = password @timeout = timeout @pool_size = pool_size @log = log end |
Instance Attribute Details
#log ⇒ Object (readonly)
Returns the value of attribute log.
270 271 272 |
# File 'lib/fluent/plugin/filter_redis_enrichment.rb', line 270 def log @log end |
Instance Method Details
#get(key) ⇒ Object
288 289 290 291 292 293 294 295 296 297 298 299 300 |
# File 'lib/fluent/plugin/filter_redis_enrichment.rb', line 288 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}'") if log nil end end |
#get_all ⇒ Object
302 303 304 305 306 307 308 309 310 |
# File 'lib/fluent/plugin/filter_redis_enrichment.rb', line 302 def get_all redis.scan_each.with_object({}) do |key, all| case @redis.type(key) when 'hash' then all[key] = @redis.hgetall(key) when 'string' then all[key] = @redis.get(key) when 'set' then all[key] = @redis.smembers(key) end end end |
#quit ⇒ Object
312 313 314 |
# File 'lib/fluent/plugin/filter_redis_enrichment.rb', line 312 def quit redis.quit end |