Package entropy :: Module cache :: Class MtimePingus

Class MtimePingus

source code


This class can be used to store on-disk mtime of executed calls. This can be handy for cache expiration validation. Example of usage:

>>> from entropy.cache import MtimePingus
>>> pingus = MtimePingus()
>>> pingus.ping("my_action_string")
>>> pingus.pong("my_action_string)
19501230123.0
>>> pingus.hours_passed("my_action_string", 3)
False
>>> pingus.minutes_passed("my_action_string", 60)
False
>>> pingus seconds_passed("my_action_string", 15)
False
Instance Methods
 
__init__(self)
x.__init__(...) initializes x; see help(type(x)) for signature
source code
 
ping(self, action_string)
Actually store a ping action mtime.
source code
float or None
pong(self, action_string)
Actually retrieve a ping action mtime.
source code
bool
seconds_passed(self, action_string, seconds)
Determine whether given seconds are passed since last ping against action_string.
source code
bool
minutes_passed(self, action_string, minutes)
Determine whether given minutes are passed since last ping against action_string.
source code
bool
hours_passed(self, action_string, hours)
Determine whether given hours are passed since last ping against action_string.
source code

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Class Variables
  PINGUS_DIR = '/var/lib/entropy/pingus_cache'
Properties

Inherited from object: __class__

Method Details

__init__(self)
(Constructor)

source code 

x.__init__(...) initializes x; see help(type(x)) for signature

Overrides: object.__init__
(inherited documentation)

ping(self, action_string)

source code 

Actually store a ping action mtime.

Parameters:
  • action_string (string) - action identifier

pong(self, action_string)

source code 

Actually retrieve a ping action mtime.

Parameters:
  • action_string (string) - action identifier
Returns: float or None
mtime (float) or None

seconds_passed(self, action_string, seconds)

source code 

Determine whether given seconds are passed since last ping against action_string. This also returns True if action_string does not exist.

Parameters:
  • action_string (string) - action identifier
  • seconds (int) - seconds passed
Returns: bool
True, if seconds are passed

minutes_passed(self, action_string, minutes)

source code 

Determine whether given minutes are passed since last ping against action_string. This also returns True if action_string does not exist.

Parameters:
  • action_string (string) - action identifier
  • minutes (int) - minutes passed
Returns: bool
True, if minutes are passed

hours_passed(self, action_string, hours)

source code 

Determine whether given hours are passed since last ping against action_string. This also returns True if action_string does not exist.

Parameters:
  • action_string (string) - action identifier
  • hours (int) - minutes passed
Returns: bool
True, if hours are passed