Class: McDump::Memcached::Item

Inherits:
Object
  • Object
show all
Defined in:
lib/mc_dump/memcached/item.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args) ⇒ Item

Returns a new instance of Item.


18
19
20
# File 'lib/mc_dump/memcached/item.rb', line 18

def initialize(args)
  @data = args
end

Class Method Details

.parse(dump, items_id) ⇒ Object


6
7
8
9
10
11
12
13
14
15
16
# File 'lib/mc_dump/memcached/item.rb', line 6

def self.parse(dump, items_id)
  dump.scan(/^ITEM (.+?) \[(\d+) b; (\d+) s\]$/).map do |item_data|
    cache_key, size_in_bytes, expires_string = item_data
    self.new(
      items_id:        items_id,
      cache_key:       cache_key,
      expiration_time: Time.at(expires_string.to_i),
      size_in_bytes:   size_in_bytes.to_i
    )
  end
end

Instance Method Details

#to_hObject


22
23
24
# File 'lib/mc_dump/memcached/item.rb', line 22

def to_h
  @data.clone
end