item key type 项目的键的类型
item value type 项目的值的类型
The maximum age of items in the cache. 缓存中项目的最大年龄(毫秒)。
The maximum size of the cache. 缓存的最大大小。
The stored item count. 缓存中存储的项目数量。
Clear the cache.
清空缓存。
Iterable for all the entries. 所有条目的迭代器。
Evict the least recently used items from the cache.
It will always keep at least one item in the cache.
从缓存中移除最近最少使用的项目。
缓存中始终至少保留一个项目。
Optionalcount: numberThe number of items to evict. Defaults to 1. 移除的项目数量。默认值为 1。
Get the remaining time to live (in milliseconds) for the given item, or undefined when the item is not in the cache.
Infinity if the item has no expiration.获取指定项目的剩余存活时间(以毫秒为单位),如果项目不在缓存中则返回 undefined。
Infinity。item key 项目的键
Remaining time to live in milliseconds when set, Infinity when there is no expiration, or undefined when the item does not exist. 设置后剩余的存活时间(毫秒),若无过期时间则为Infinity,若项目不存在则为undefined。
Returns a specified element from the Map object.
If no element is associated with the specified key, a new element with the value defaultValue will be inserted into the Map and returned.
The element associated with the specified key, which will be defaultValue if no element previously existed.
Returns a specified element from the Map object.
If no element is associated with the specified key, the result of passing the specified key to the callback function will be inserted into the Map and returned.
The element associated with the specific key, which will be the newly computed value if no element previously existed.
Iterable for all the keys. 所有键的迭代器。
Update the maxSize in-place, discarding items as necessary. Insertion order is mostly preserved, though this is not a strong guarantee.
Useful for on-the-fly tuning of cache sizes in live systems.
就地更新 maxSize,必要时丢弃项目。插入顺序基本保留,但这不是一个强保证。
适用于在线系统中动态调整缓存大小。
Optionalsize: numbercache size 缓存大小
Set an item. Returns the instance.
Individual expiration of an item can be specified with the maxAge option.
If not specified, the global maxAge value will be used in case
it is specified in the constructor; otherwise the item will never expire.
设置一个项目。返回实例。
可以使用 maxAge 选项指定单个项目的过期时间。
如果未指定,当构造函数中指定了全局 maxAge 值时,将使用该值;否则项目永不过期。
item key 项目的键
item value 项目的值
Optionaloptions: LRUCacheSetOptionsitem options 项目的选项
LRU Cache Set Options
LRU 缓存 Set 选项
OptionalmaxAge?: numberThe maximum number of milliseconds an item should remain in the cache.
项目在缓存中保留的最大毫秒数。
instance 实例
Returns a string representation of an object.
Iterable for all the values. 所有值的迭代器。
Staticgroup
LRU Cache
Example