获取缓存的容量限制 Get the capacity limit of the cache
缓存的最大容量 Maximum capacity of the cache
获取当前缓存的大小(已存储的项数) Get the current size of the cache (number of stored items)
缓存中当前存储的项数 Number of items currently stored in the cache
清空缓存中的所有项 Clear all items from the cache
删除缓存中指定的键 Delete the specified key from the cache
要删除的键 Key to delete
如果键存在并被删除返回 true,否则返回 false Returns true if key existed and was deleted, false otherwise
从缓存中获取指定键的值 Get the value of the specified key from the cache
获取操作会使该键成为最近使用的项(LRU 特性)。
The get operation makes this key the most recently used item (LRU feature).
要获取的键 Key to get
如果键存在返回对应的值,否则返回 undefined Returns the corresponding value if key exists, undefined otherwise
检查缓存中是否存在指定的键 Check if the specified key exists in the cache
要检查的键 Key to check
如果键存在返回 true,否则返回 false Returns true if key exists, false otherwise
向缓存中添加或更新键值对 Add or update a key-value pair in the cache
如果键已存在,会先删除旧记录再添加新记录, 这样能确保该键成为最近使用的项。
If the key already exists, it will delete the old record before adding the new one, ensuring this key becomes the most recently used item.
如果添加后缓存大小超过容量限制,会自动移除最久未使用的项。
If the cache size exceeds capacity after adding, it automatically removes the least recently used item.
LRU (Least Recently Used) 缓存类 LRU (Least Recently Used) Cache Class
基于最近最少使用原则的缓存实现,当缓存达到容量上限时, 会自动移除最久未被访问的项。
Implementation of cache based on Least Recently Used principle. When the cache reaches its capacity limit, it automatically removes the least recently accessed item.