 |
ATLAS Offline Software
|
Go to the documentation of this file.
14 self.
cachedir = cachedir.rstrip(
'/')
if os.path.exists(cachedir)
else None
17 print (
"Initializing the cache at",cachedir.rstrip(
'/'))
24 print (
"Providing cache functionality for function '%s()'" % f.func_name)
25 def newf(*args, **kwds):
26 key = kwds[
'cachekey']
31 print (
"DEBUG: returning cached value for '%s'" % (self.
form % key))
37 filename = self.
form % key
38 return '%s/%s.pickle' % (self.
cachedir, filename)
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))
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))
80 if __name__ ==
"__main__":
81 @
Cache(
"/afs/cern.ch/user/s/stelzer/runsummary/cache/",
"simple_%i_second%i")
def __write_to_cache(self, key, value)
def __call__(self, f, *args, **kwds)
def aFunction(x, y, cachekey)
def __is_cached(self, key)
def __name_pickle_cache(self, key)
def __init__(self, cachedir, form)