class Fluent::Plugin::MemcachedOutput

Constants

DEFAULT_BUFFER_TYPE
DEFAULT_FORMAT_TYPE

Attributes

formatter[RW]
memcached[RW]

Public Instance Methods

configure(conf) click to toggle source
Calls superclass method
# File lib/fluent/plugin/out_memcached.rb, line 35
def configure(conf)
  compat_parameters_convert(conf, :buffer, :inject, :formatter)
  super

  @formatter = formatter_create
end
format(tag, time, record) click to toggle source
# File lib/fluent/plugin/out_memcached.rb, line 54
def format(tag, time, record)
  record = inject_values_to_record(tag, time, record)

  key = @include_key ? record[@key] : record.delete(@key)
  [time, key, @formatter.format(tag, time, record).chomp].to_msgpack
end
formatted_to_msgpack_binary?() click to toggle source
# File lib/fluent/plugin/out_memcached.rb, line 61
def formatted_to_msgpack_binary?
  true
end
multi_workers_ready?() click to toggle source
# File lib/fluent/plugin/out_memcached.rb, line 65
def multi_workers_ready?
  true
end
shutdown() click to toggle source
Calls superclass method
# File lib/fluent/plugin/out_memcached.rb, line 48
def shutdown
  @memcached.close

  super
end
start() click to toggle source
Calls superclass method
# File lib/fluent/plugin/out_memcached.rb, line 42
def start
  super

  @memcached = Dalli::Client.new("#{@host}:#{@port}")
end
write(chunk) click to toggle source
# File lib/fluent/plugin/out_memcached.rb, line 69
def write(chunk)
  chunk.msgpack_each do |time, key, value|
    unless @increment
      @memcached.set(key, value)
      next
    end

    @memcached.incr(key, value.to_i, nil, value.to_i)
  end
end