Definition at line 12 of file AtlRunQueryCache.py.
◆ __init__()
def python.utils.AtlRunQueryCache.Cache.__init__ |
( |
|
self, |
|
|
|
cachedir, |
|
|
|
form |
|
) |
| |
Definition at line 13 of file AtlRunQueryCache.py.
15 self.cachedir = cachedir.rstrip(
'/')
if os.path.exists(cachedir)
else None
18 print (
"Initializing the cache at",cachedir.rstrip(
'/'))
◆ __call__()
def python.utils.AtlRunQueryCache.Cache.__call__ |
( |
|
self, |
|
|
|
f, |
|
|
* |
args, |
|
|
** |
kwds |
|
) |
| |
Definition at line 21 of file AtlRunQueryCache.py.
21 def __call__(self, f, *args, **kwds):
25 print (
"Providing cache functionality for function '%s()'" % f.func_name)
26 def newf(*args, **kwds):
27 key = kwds[
'cachekey']
28 if not self.__is_cached(key):
29 self.__write_to_cache(key,
f(*args, **kwds))
32 print (
"DEBUG: returning cached value for '%s'" % (self.form % key))
34 return self._cache[key]
◆ __is_cached()
def python.utils.AtlRunQueryCache.Cache.__is_cached |
( |
|
self, |
|
|
|
key |
|
) |
| |
|
private |
Definition at line 56 of file AtlRunQueryCache.py.
56 def __is_cached(self,key):
58 if key
in self._cache:
62 pfname = self.__name_pickle_cache(key)
64 pf =
open( pfname,
'r' )
67 print (
'DEBUG: could not read from cache: ' + pfname)
70 self._cache[key] = pickle.load(pf)
71 except pickle.UnpicklingError
as err:
72 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 37 of file AtlRunQueryCache.py.
37 def __name_pickle_cache(self,key):
38 filename = self.form % key
39 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 42 of file AtlRunQueryCache.py.
42 def __write_to_cache(self,key, value):
44 self._cache[key] = value
47 pfname = self.__name_pickle_cache(key)
48 pf =
open( pfname,
'w' )
50 pickle.dump(value, pf)
51 except pickle.PicklingError
as err:
52 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: