modulepackage
0.0.0-20190726002235-7b5ae3605bad
Repository: https://github.com/samkumar/reqcache.git
Documentation: pkg.go.dev
# README
LRU Cache with Request Management
This implements an LRU cache for a I/O resource. On a cache miss, the cache requests the resource, blocking until it is available. The cache has the property that if multiple requests are concurrently made for a resource that is not in the cache, then only one request for the resource is made, and all requests block until it is available.
Because this library is designed for caching resources that require an I/O to fetch, it is fully concurrent. Fetches are made without holding any locks, meaning that:
- While one operation is blocking due to a cache miss, additional operations on the cache will not block.
- Multiple fetches for resources can be concurrently pending.
This library is also context-aware.
License
This library is licensed under the BSD 3-Clause License, but can also be licensed under the GNU GPL v3 License and freely used in projects licensed as GNU GPL v3.
# Functions
NewLRUCache returns a new instance of LRUCache.
# Constants
Missing status indicates that the specified item is not in the cache, and that there is no outstanding request for the item.
Pending status indicates that the specified item is not in the cache, but that there is a pending request for the item.
Present status indicates that the specified item is in the cache.
# Structs
LRUCache represents a cache with the LRU eviction policy.
LRUCacheEntry represents an entry in the LRU Cache.
# Type aliases
CacheStatus describes the presence of an item in the cache.