MCPcopy Create free account
hub / github.com/PacktPublishing/System-Programming-Essentials-with-Go / NewCache

Function NewCache

ch13/cache.go:30–36  ·  view source on GitHub ↗

NewCache initializes and returns a new Cache with the given capacity

(capacity int)

Source from the content-addressed store, hash-verified

28
29// NewCache initializes and returns a new Cache with the given capacity
30func NewCache(capacity int) *Cache {
31 return &Cache{
32 items: make(map[string]*list.Element),
33 eviction: list.New(),
34 capacity: capacity,
35 }
36}
37
38// Set adds or updates a cache entry with the specified key, value, and TTL
39func (c *Cache) Set(key, value string, ttl time.Duration) {

Callers 9

NewCacheServerFunction · 0.85
TestCacheInitializationFunction · 0.85
TestCacheEvictsLRUFunction · 0.85
TestCacheConcurrencyFunction · 0.85

Calls

no outgoing calls