MemoryStorage
public enum MemoryStorage
Represents a set of conception related to storage which stores a certain type of value in memory.
This is a namespace for the memory storage types. A Backend
with a certain Config
will be used to describe the
storage. See these composed types for more information.
-
Represents a storage which stores a certain type of value in memory. It provides fast access, but limited storing size. The stored value type needs to conform to
CacheCostCalculable
, and itscacheCost
will be used to determine the cost of size for the cache item.You can config a
See moreMemoryStorage.Backend
in its initializer by passing aMemoryStorage.Config
value. or modifying theconfig
property after it being created. The backend ofMemoryStorage
has upper limitation on cost size in memory and item count. All items in the storage has an expiration date. When retrieved, if the target item is already expired, it will be recognized as it does not exist in the storage. TheMemoryStorage
also contains a scheduled self clean task, to evict expired items from memory.Declaration
Swift
public class Backend<T> where T : CacheCostCalculable
-
Represents the config used in a
See moreMemoryStorage
.Declaration
Swift
public struct Config