Cache Utils

class agilerl.utils.cache.Cache(cache_init: dict | None = None)

Bases: object

dump(file_name: str) None

Dump the cache to a file.

Parameters:

file_name (str) – Name of the file to dump the cache to.

get_cache() dict

Get the cache.

Returns:

Cache.

Return type:

dict

get_hit_rate() float

Get the hit rate of the cache.

Returns:

Hit rate of the cache.

Return type:

float

items() list[tuple[str, Any]]

Get the items of the cache.

Returns:

Items of the cache.

Return type:

list

keys() list[str]

Get the keys of the cache.

Returns:

Keys of the cache.

Return type:

list

load(file_name: str) None

Load the cache from a file.

Parameters:

file_name (str) – Name of the file to load the cache from.

update(new_stuff: dict) None

Update the cache with new items.

Parameters:

new_stuff (dict) – New items to update the cache with.

values() list[Any]

Get the values of the cache.

Returns:

Values of the cache.

Return type:

list