Method: InstantCache::Counter.memcached_counter
- Defined in:
- lib/instantcache.rb
.memcached_counter(*args, &block) ⇒ Object
Description
Access method declarator for an interlocked shared integer memcache-backed variable.
This declarator sets up several methods relating to the variable. If the name passed is :ivar, these methods are created for it:
- ivar
-
Normal read accessor (e.g.,
obj.ivar). (See Blob#get) - ivar_reset
-
Resets the cache variable to the default ‘uninitialised’ value. (See Blob#reset)
- ivar_expiry
-
Returns the current cache lifetime (default 0). (See Blob#expiry)
- ivar_expiry=
-
Sets the cache lifetime. (See Blob#expiry=)
- ivar_lock
-
Tries to get an exclusive lock on the variable. (See Blob#lock)
- ivar_unlock
-
Unlocks the variable if locked. (See Blob#unlock)
- ivar_destroyed?
-
Returns true if variable is disconnected from the cache and unusable. (See Blob#destroyed?)
- ivar_destroy!
-
Disconnects the variable from the cache and makes it unusable. (See Blob#destroy!)
(These are the same methods created for a Blob::memcached_accessor declaration.)
In addition, the following counter-specific methods are created:
- ivar_increment
-
Adds the specified value to the cache variable. (See Counter#increment)
- ivar_incr
-
Alias for
ivar_increment. - ivar_decrement
-
Subtracts from the cache variable. (See Counter#decrement)
- ivar_decr
-
Alias for
ivar_decrement.
:call-seq: memcached_counter(symbol[,…]) memcached_counter(symbol[,…]) { |symbol| … }
Arguments
- symbol
-
As with other Ruby accessor declarations, the argument list consists of one or more variable names represented as symbols (e.g.,
:variablename). - block
-
If a block is supplied, its return value must be a string, which will be used as the name of the memcached cell backing the variable. The argument to the block is the name of the variable as passed to the accessor declaration.
Exceptions
None.
– This will be overridden later, but we need to declare something for the rdoc generation to work. ++
858 |
# File 'lib/instantcache.rb', line 858 def memcached_counter(*args, &block) ; end |