This module provides the base interface for a Cache data structure: a simple in-memory key-value storage,
which can be useful to organize cache data structures.
The submodules contain different implementations for that interface. The main module re-exports these implementations:
// Cause we use the same instance for the local data storing, // this cache will have all values from the previous (it will be loaded from the storage during initialization)
core/cache
This module provides the base interface for a Cache data structure: a simple in-memory key-value storage, which can be useful to organize cache data structures. The submodules contain different implementations for that interface. The main module re-exports these implementations:
AbstractCache
— an alias forcore/cache/interface/Cache
;Cache
— an alias forcore/cache/simple
;RestrictedCache
— an alias forcore/cache/restricted
;NeverCache
— an alias forcore/cache/never
.Iterators
All caches support three kinds of iterators:
Decorators
Also, the module provides a bunch of functions to decorate cache storages, like adding the
ttl
feature or persisting data storing.core/cache/decorators/ttl
Provides a decorator for any cache to add a feature of cache expiring.
core/cache/decorators/persistent
Provides a decorator for any cache to add a feature of persistent data storing.
API
Ranges support a bunch of methods to work with them.
size (getter)
Number of elements within the cache.
has
Returns true if a value by the specified key exists in the cache.
get
Returns a value from the cache by the specified key.
set
Saves a value to the cache by the specified key.
remove
Removes a value from the cache by the specified key.
clear
Clears the cache by the specified filter and returns a map of removed keys.