DictCache¶

DictCache.

class DIRAC.Core.Utilities.DictCache.DictCache(deleteFunction=False)

Bases: object

class DictCache

simple dict cache

__init__(deleteFunction=False)
Initialize the dict cache.
If a delete function is specified it will be invoked when deleting a cached object
add(cKey, validSeconds, value=None)

Add a record to the cache

Parameters: cKey – identification key of the record validSeconds – valid seconds of this record value – value of the record
delete(cKey)

Delete a key from the cache

Parameters: cKey – identification key of the record
exists(cKey, validSeconds=0)

Returns True/False if the key exists for the given number of seconds Arguments: :param cKey: identification key of the record :param validSeconds: The amount of seconds the key has to be valid for

get(cKey, validSeconds=0)

Get a record from the cache

Parameters: cKey – identification key of the record validSeconds – The amount of seconds the key has to be valid for
getKeys(validSeconds=0)

Get keys for all contents

lock
purgeAll(useLock=True)

Purge all entries CAUTION: useLock parameter should ALWAYS be True except when called from __del__

purgeExpired(expiredInSeconds=0)

Purge all entries that are expired or will be expired in <expiredInSeconds>

showContentsInString()

Return a human readable string to represent the contents