ttl_map (util v1.3.5)
View SourceMap with TTL key/value eviction.
An insert of a Key/Value pair in the map will store the timestamp of the maybe_add. Additionally a queue of maybe_adds is maintained by this container, which is checked on each insert and the expired Key/Value pairs are evicted from the map.
Author: Serge Aleynikov <saleyn at gmail dot com>
Summary
Functions
Evict stale items from the map given the current timestamp Now.
Evict stale items (up to the Limit) from the map given the current timestamp
Now.
Create a new map with a given TTL time for inserted items
Create a new map with a given TTL time for inserted items. Opts is a list of
options
Get the current timestamp in microseconds since Unix epoch.
Get the number of items in the map.
Try to add a Key/Value pair to the map. If more than TTL time elapsed since
the last insert of the Key or the Key is not found in the map, the value is
inserted, otherwise no insertion is made.
Types
Functions
-spec evict(ttl_map(), non_neg_integer()) -> ttl_map().
Evict stale items from the map given the current timestamp Now.
-spec evict(ttl_map(), non_neg_integer(), non_neg_integer()) -> ttl_map().
Evict stale items (up to the Limit) from the map given the current timestamp
Now.
Create a new map with a given TTL time for inserted items
Create a new map with a given TTL time for inserted items. Opts is a list of
options:
name— The name of the ETS table (defaults toundefined)access— The access level of the ETS table (defaults toprivate)
-spec now() -> non_neg_integer().
Get the current timestamp in microseconds since Unix epoch.
-spec size(ttl_map()) -> non_neg_integer().
Get the number of items in the map.
Try to add a Key/Value pair to the map. If more than TTL time elapsed since
the last insert of the Key or the Key is not found in the map, the value is
inserted, otherwise no insertion is made.