redis_func_cache.policies.base module#

Base class for single-pair cache.

class redis_func_cache.policies.base.BaseClusterMultiplePolicy[source]#

Bases: BaseMultiplePolicy

Base policy for multiple sorted-set or hash-map key pairs with Redis cluster support.

Inheritance diagram of BaseClusterMultiplePolicy

Each decorated function using this policy has its own Redis key pair.

Not intended for direct use.

Parameters:

cache – Optional weakref proxy to the RedisFuncCache instance using this policy.

Note

The cache argument may be omitted when instantiating a policy. The RedisFuncCache will bind itself to the policy instance by setting this attribute to a weakref proxy during cache construction.

calc_keys(f=None, args=None, kwds=None)[source]#

Calculate a unique Redis key pair for the given function, using cluster hash tags.

Parameters:
Return type:

tuple[str, str]

Returns:

Tuple of (sorted set key, hash map key).

class redis_func_cache.policies.base.BaseClusterSinglePolicy[source]#

Bases: BaseSinglePolicy

Base policy for a single sorted-set or hash-map key pair with Redis cluster support.

Inheritance diagram of BaseClusterSinglePolicy

All decorated functions using this policy share the same Redis key pair.

Not intended for direct use.

Parameters:

cache – Optional weakref proxy to the RedisFuncCache instance using this policy.

Note

The cache argument may be omitted when instantiating a policy. The RedisFuncCache will bind itself to the policy instance by setting this attribute to a weakref proxy during cache construction.

calc_keys(f=None, args=None, kwds=None)[source]#

Return the static Redis key pair for this cache policy, using cluster hash tags.

Return type:

tuple[str, str]

Returns:

Tuple of (sorted set key, hash map key).

Parameters:
class redis_func_cache.policies.base.BaseMultiplePolicy[source]#

Bases: AbstractPolicy

Base policy for multiple sorted-set or hash-map key pairs.

Inheritance diagram of BaseMultiplePolicy

Each decorated function using this policy has its own Redis key pair.

Not intended for direct use.

Parameters:

cache – Optional weakref proxy to the RedisFuncCache instance using this policy.

Note

The cache argument may be omitted when instantiating a policy. The RedisFuncCache will bind itself to the policy instance by setting this attribute to a weakref proxy during cache construction.

async apurge()[source]#

Delete all Redis keys for this policy asynchronously.

Return type:

int

Returns:

Number of keys deleted.

calc_keys(f=None, args=None, kwds=None)[source]#

Calculate a unique Redis key pair for the given function.

Parameters:
Return type:

tuple[str, str]

Returns:

Tuple of (sorted set key, hash map key).

purge()[source]#

Delete all Redis keys for this policy synchronously.

Return type:

int

Returns:

Number of keys deleted.

class redis_func_cache.policies.base.BaseSinglePolicy[source]#

Bases: AbstractPolicy

Base policy for a single sorted-set or hash-map key pair.

Inheritance diagram of BaseSinglePolicy

All decorated functions using this policy share the same Redis key pair.

Not intended for direct use.

Parameters:

cache – Optional weakref proxy to the RedisFuncCache instance using this policy.

Note

The cache argument may be omitted when instantiating a policy. The RedisFuncCache will bind itself to the policy instance by setting this attribute to a weakref proxy during cache construction.

async aget_size()[source]#

Get the number of items in the cache asynchronously.

Return type:

int

Returns:

Number of items in the cache.

async apurge()[source]#

Delete the cache’s Redis keys asynchronously.

Return type:

int

Returns:

Number of keys deleted.

calc_keys(f=None, args=None, kwds=None)[source]#

Return the static Redis key pair for this cache policy.

Return type:

tuple[str, str]

Returns:

Tuple of (sorted set key, hash map key).

Parameters:
get_size()[source]#

Get the number of items in the cache synchronously.

Return type:

int

Returns:

Number of items in the cache.

purge()[source]#

Delete the cache’s Redis keys synchronously.

Return type:

int

Returns:

Number of keys deleted.