Definition at line 11 of file AtlRunQueryCache.py.
◆ __init__()
def python.utils.AtlRunQueryCache.Cache.__init__ |
( |
|
self, |
|
|
|
cachedir, |
|
|
|
form |
|
) |
| |
Definition at line 12 of file AtlRunQueryCache.py.
14 self.cachedir = cachedir.rstrip(
'/')
if os.path.exists(cachedir)
else None
17 print (
"Initializing the cache at",cachedir.rstrip(
'/'))
◆ __call__()
def python.utils.AtlRunQueryCache.Cache.__call__ |
( |
|
self, |
|
|
|
f, |
|
|
* |
args, |
|
|
** |
kwds |
|
) |
| |
Definition at line 20 of file AtlRunQueryCache.py.
20 def __call__(self, f, *args, **kwds):
24 print (
"Providing cache functionality for function '%s()'" % f.func_name)
25 def newf(*args, **kwds):
26 key = kwds[
'cachekey']
27 if not self.__is_cached(key):
28 self.__write_to_cache(key,
f(*args, **kwds))
31 print (
"DEBUG: returning cached value for '%s'" % (self.form % key))
33 return self._cache[key]
◆ __is_cached()
def python.utils.AtlRunQueryCache.Cache.__is_cached |
( |
|
self, |
|
|
|
key |
|
) |
| |
|
private |
Definition at line 55 of file AtlRunQueryCache.py.
55 def __is_cached(self,key):
57 if key
in self._cache:
61 pfname = self.__name_pickle_cache(key)
63 pf =
open( pfname,
'r' )
66 print (
'DEBUG: could not read from cache: ' + pfname)
69 self._cache[key] = pickle.load(pf)
70 except pickle.UnpicklingError
as err:
71 print (
"ERROR: could not unpickle %s (%s)" % (pfname, err))
◆ __name_pickle_cache()
def python.utils.AtlRunQueryCache.Cache.__name_pickle_cache |
( |
|
self, |
|
|
|
key |
|
) |
| |
|
private |
Definition at line 36 of file AtlRunQueryCache.py.
36 def __name_pickle_cache(self,key):
37 filename = self.form % key
38 return '%s/%s.pickle' % (self.cachedir, filename)
◆ __write_to_cache()
def python.utils.AtlRunQueryCache.Cache.__write_to_cache |
( |
|
self, |
|
|
|
key, |
|
|
|
value |
|
) |
| |
|
private |
Definition at line 41 of file AtlRunQueryCache.py.
41 def __write_to_cache(self,key, value):
43 self._cache[key] = value
46 pfname = self.__name_pickle_cache(key)
47 pf =
open( pfname,
'w' )
49 pickle.dump(value, pf)
50 except pickle.PicklingError
as err:
51 print (
'ERROR: could not write to cache: %s (%s)' % (pfname, err))
◆ _cache
python.utils.AtlRunQueryCache.Cache._cache |
|
private |
◆ cachedir
python.utils.AtlRunQueryCache.Cache.cachedir |
◆ form
python.utils.AtlRunQueryCache.Cache.form |
The documentation for this class was generated from the following file: