Class: MemcachedTest::Memcached_item

Inherits:
Object
  • Object
show all
Defined in:
lib/memcached_test/memcached_item.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(flags, exptime, bytes, cas, data) ⇒ Memcached_item

Returns a new instance of Memcached_item.



10
11
12
13
14
15
16
# File 'lib/memcached_test/memcached_item.rb', line 10

def initialize(flags, exptime, bytes, cas, data)
    @flags = flags
    @exptime = set_exptime(exptime)
    @bytes = bytes
    @cas = cas
    @data = data
end

Instance Attribute Details

#bytesObject

Returns the value of attribute bytes.



6
7
8
# File 'lib/memcached_test/memcached_item.rb', line 6

def bytes
  @bytes
end

#casObject

Returns the value of attribute cas.



7
8
9
# File 'lib/memcached_test/memcached_item.rb', line 7

def cas
  @cas
end

#dataObject

Returns the value of attribute data.



8
9
10
# File 'lib/memcached_test/memcached_item.rb', line 8

def data
  @data
end

#exptimeObject

Returns the value of attribute exptime.



5
6
7
# File 'lib/memcached_test/memcached_item.rb', line 5

def exptime
  @exptime
end

#flagsObject

Returns the value of attribute flags.



4
5
6
# File 'lib/memcached_test/memcached_item.rb', line 4

def flags
  @flags
end

Instance Method Details

#set_exptime(exptime) ⇒ Object



18
19
20
21
22
23
24
25
26
# File 'lib/memcached_test/memcached_item.rb', line 18

def set_exptime(exptime)
    if exptime.to_i == 0
        return nil
    elsif exptime.to_i < 2592000
        return Time.now().getutc() + exptime.to_i
    else
        return Time.at(exptime.to_i)
    end
end