Package pyxmpp :: Module cache :: Class CacheItem
[show private | hide private]
[frames | no frames]

Type CacheItem

object --+
         |
        CacheItem


An item in a cache.
Method Summary
  __init__(self, address, value, freshness_period, expiration_period, purge_period, state)
Initialize an CacheItem object.
  __cmp__(self, other)
datetime update_state(self)
Update current status of the item and compute time of the next state change.
    Inherited from object
  __delattr__(...)
x.__delattr__('name') <==> del x.name
  __getattribute__(...)
x.__getattribute__('name') <==> x.name
  __hash__(x)
x.__hash__() <==> hash(x)
  __new__(T, S, ...)
T.__new__(S, ...) -> a new object with type S, a subtype of T
  __reduce__(...)
helper for pickle
  __reduce_ex__(...)
helper for pickle
  __repr__(x)
x.__repr__() <==> repr(x)
  __setattr__(...)
x.__setattr__('name', value) <==> x.name = value
  __str__(x)
x.__str__() <==> str(x)

Instance Variable Summary
any hashable address: item address.
datetime expire_time: time when the object expires.
datetime freshness_time: time when the object stops being fresh.
datetime purge_time: time when the object should be purged.
str state: current state.
int state_value: numerical value of the current state (lower number means fresher item).
datetime timestamp: time when the object was created.
instance value: item value (cached object).

Class Variable Summary
list __slots__ = ['value', 'address', 'state', 'timestamp', '...

Method Details

__init__(self, address, value, freshness_period, expiration_period, purge_period, state='new')
(Constructor)

Initialize an CacheItem object.
Parameters:
address - item address.
           (type=any hashable)
value - item value (cached object).
           (type=instance)
freshness_period - time interval after which the object stops being fresh.
           (type=timedelta)
expiration_period - time interval after which the object expires.
           (type=timedelta)
purge_period - time interval after which the object should be purged. When 0 then item will never be automaticaly purged.
           (type=timedelta)
state - initial state.
           (type=str)
Overrides:
__builtin__.object.__init__

update_state(self)

Update current status of the item and compute time of the next state change.
Returns:
the new state.
           (type=datetime)

Instance Variable Details

address

item address.
Type:
any hashable
Value:
<member 'address' of 'CacheItem' objects>                              

expire_time

time when the object expires.
Type:
datetime
Value:
<member 'expire_time' of 'CacheItem' objects>                          

freshness_time

time when the object stops being fresh.
Type:
datetime
Value:
<member 'freshness_time' of 'CacheItem' objects>                       

purge_time

time when the object should be purged. When 0 then item will never be automaticaly purged.
Type:
datetime
Value:
<member 'purge_time' of 'CacheItem' objects>                           

state

current state.
Type:
str
Value:
<member 'state' of 'CacheItem' objects>                                

state_value

numerical value of the current state (lower number means fresher item).
Type:
int
Value:
<member 'state_value' of 'CacheItem' objects>                          

timestamp

time when the object was created.
Type:
datetime
Value:
<member 'timestamp' of 'CacheItem' objects>                            

value

item value (cached object).
Type:
instance
Value:
<member 'value' of 'CacheItem' objects>                                

Class Variable Details

__slots__

Type:
list
Value:
['value',
 'address',
 'state',
 'timestamp',
 'freshness_time',
 'expire_time',
 'purge_time',
 'state_value',
...