Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cache ¶
type Cache struct {
// contains filtered or unexported fields
}
Cache represents a distributed cache with multiple shards for concurrency and efficiency. Each shard manages a subset of cache entries to reduce contention.
func New ¶
Initializes and returns a new `Cache` instance. It distributes the capacity evenly across all shards.
func (*Cache) Get ¶
func (c *Cache) Get(req *pb.GetRequest) (*pb.GetResponse, bool)
Retrieves a cache entry by key and returns a GetResponse if the key exists and has not expired. If the item is found, it is moved to the front of the eviction list to mark it as recently used.
func (*Cache) Set ¶
func (c *Cache) Set(req *pb.SetRequest)
Set adds or updates a cache entry with the specified key and value from the SetRequest. If the cache exceeds its capacity, the least-recently-used (LRU) item is evicted.
Click to show internal directories.
Click to hide internal directories.