Class: Fluent::MemcachedOutput
- Inherits:
-
BufferedOutput
- Object
- BufferedOutput
- Fluent::MemcachedOutput
- Defined in:
- lib/fluent/plugin/out_memcached.rb
Instance Attribute Summary collapse
-
#host ⇒ Object
readonly
Returns the value of attribute host.
-
#memcached ⇒ Object
readonly
Returns the value of attribute memcached.
-
#port ⇒ Object
readonly
Returns the value of attribute port.
Instance Method Summary collapse
- #configure(conf) ⇒ Object
- #format(tag, time, record) ⇒ Object
-
#initialize ⇒ MemcachedOutput
constructor
A new instance of MemcachedOutput.
- #shutdown ⇒ Object
- #start ⇒ Object
- #write(chunk) ⇒ Object
Constructor Details
#initialize ⇒ MemcachedOutput
Returns a new instance of MemcachedOutput.
5 6 7 8 |
# File 'lib/fluent/plugin/out_memcached.rb', line 5 def initialize super require 'dalli' end |
Instance Attribute Details
#host ⇒ Object (readonly)
Returns the value of attribute host.
3 4 5 |
# File 'lib/fluent/plugin/out_memcached.rb', line 3 def host @host end |
#memcached ⇒ Object (readonly)
Returns the value of attribute memcached.
3 4 5 |
# File 'lib/fluent/plugin/out_memcached.rb', line 3 def memcached @memcached end |
#port ⇒ Object (readonly)
Returns the value of attribute port.
3 4 5 |
# File 'lib/fluent/plugin/out_memcached.rb', line 3 def port @port end |
Instance Method Details
#configure(conf) ⇒ Object
10 11 12 13 14 |
# File 'lib/fluent/plugin/out_memcached.rb', line 10 def configure(conf) super @host = conf.has_key?('host') ? conf['host'] : 'localhost' @port = conf.has_key?('port') ? conf['port'].to_i : 11211 end |
#format(tag, time, record) ⇒ Object
25 26 27 |
# File 'lib/fluent/plugin/out_memcached.rb', line 25 def format(tag, time, record) [tag, time, record].to_msgpack end |
#shutdown ⇒ Object
21 22 23 |
# File 'lib/fluent/plugin/out_memcached.rb', line 21 def shutdown @memcached.close end |
#start ⇒ Object
16 17 18 19 |
# File 'lib/fluent/plugin/out_memcached.rb', line 16 def start super @memcached = Dalli::Client.new("#{host}:#{port}") end |
#write(chunk) ⇒ Object
29 30 31 32 33 34 35 |
# File 'lib/fluent/plugin/out_memcached.rb', line 29 def write(chunk) chunk.msgpack_each { |tag, time, record| key = record.values.first value = record.values.drop(1).join(' ') @memcached.set key, value } end |