RSSCacheNoThread

Cache

This module provides a generic Cache extended to be used on RSS, RSSCache. This cache features a lazy update method. It will only be updated if it is empty and there is a new query. If not, it will remain in its previous state. However, Cache class internal cache: DictCache sets a validity to its entries. After that, the cache is empty.

class DIRAC.ResourceStatusSystem.Utilities.RSSCacheNoThread.Cache(lifeTime, updateFunc)

Bases: object

Cache basic class.

WARNING: None of its methods is thread safe. Acquire / Release lock when using them !

acquireLock()

Acquires Cache lock

cacheKeys()

Cache keys getter

Returns:list with valid keys on the cache
get(cacheKeys)

Gets values for cacheKeys given, if all are found ( present on the cache and valid ), returns S_OK with the results. If any is not neither present not valid, returns S_ERROR.

Parameters:
cacheKeys - list

list of keys to be extracted from the cache

Returns:

S_OK | S_ERROR

refreshCache()

Purges the cache and gets fresh data from the update function.

Returns:S_OK | S_ERROR. If the first, its content is the new cache.
releaseLock()

Releases Cache lock

class DIRAC.ResourceStatusSystem.Utilities.RSSCacheNoThread.RSSCache(lifeTime, updateFunc)

Bases: DIRAC.ResourceStatusSystem.Utilities.RSSCacheNoThread.Cache

The RSSCache is an extension of Cache in which the cache keys are pairs of the form: ( elementName, statusType ).

When instantiating one object of RSSCache, we need to specify the RSS elementType it applies, e.g. : StorageElement, CE, Queue, …

It provides a unique public method match which is thread safe. All other methods are not !!

acquireLock()

Acquires Cache lock

cacheKeys()

Cache keys getter

Returns:list with valid keys on the cache
get(cacheKeys)

Gets values for cacheKeys given, if all are found ( present on the cache and valid ), returns S_OK with the results. If any is not neither present not valid, returns S_ERROR.

Parameters:
cacheKeys - list

list of keys to be extracted from the cache

Returns:

S_OK | S_ERROR

match(elementNames, elementType, statusTypes)

In first instance, if the cache is invalid, it will request a new one from the server. It make the Cartesian product of elementNames x statusTypes to generate a key set that will be compared against the cache set. If the first is included in the second, we have a positive match and a dictionary will be returned. Otherwise, we have a cache miss.

However, arguments ( elementNames or statusTypes ) can have a None value. If that is the case, they are considered wildcards.

Parameters:
elementNames - [ None, string, list ]

name(s) of the elements to be matched

elementType - [ string ]

type of the elements to be matched

statusTypes - [ None, string, list ]

name(s) of the statusTypes to be matched

Returns:

S_OK() || S_ERROR()

refreshCache()

Purges the cache and gets fresh data from the update function.

Returns:S_OK | S_ERROR. If the first, its content is the new cache.
releaseLock()

Releases Cache lock