class MemcachedServer::Item
Class that wraps up a Memcached Item
Attributes
The bite size of <data_block>
@return [Integer]
A unique integer value
@return [Integer]
Is a chunk of arbitrary 8-bit data of length <bytes>
@return [Hash]
The expiration time
@return [Integer]
Is an arbitrary unsigned integer (written out in decimal)
@return [Integer]
The key under which the client asks to store the data
@return [String]
A simple semaphore that can be used to coordinate access to shared data from multiple concurrent threads.
@return [Mutex]
Public Class Methods
# File lib/memcached-server/item.rb, line 43 def initialize(key, flags, exptime, bytes, data_block) @key = key @flags = flags @exptime = get_exptime(exptime) @bytes = bytes @data_block = data_block @lock = Mutex.new() end
Public Instance Methods
Checks if a MemcachedServer::Item
instance is expired
@return [Boolean] true if it's expired and otherwise false
# File lib/memcached-server/item.rb, line 92 def expired?() return true if (!@exptime.nil?()) && (Time.now().getutc() > @exptime) return false end
Parses the exptime of the MemcachedServer::Item
instance
@param exptime [Integer] The expiration time @return [Time, nil] The expiration time
# File lib/memcached-server/item.rb, line 81 def get_exptime(exptime) return nil if exptime == 0 return Time.now().getutc() if exptime < 0 return Time.now().getutc() + exptime end
Updates the MemcachedServer::Item
cas_id
with the corresponding next value read from last_cas_id class variable
# File lib/memcached-server/item.rb, line 71 def update_cas_id() @cas_id = get_cas_id() end