MCPcopy Create free account
hub / github.com/convox/rack / Set

Function Set

pkg/cache/cache.go:54–74  ·  view source on GitHub ↗
(collection string, key, value interface{}, ttl time.Duration)

Source from the content-addressed store, hash-verified

52}
53
54func Set(collection string, key, value interface{}, ttl time.Duration) error {
55 lock.Lock()
56 defer lock.Unlock()
57
58 if cache[collection] == nil {
59 cache[collection] = map[string]*CacheItem{}
60 }
61
62 hash, err := hashKey(key)
63
64 if err != nil {
65 return err
66 }
67
68 cache[collection][hash] = &CacheItem{
69 Item: value,
70 Expires: time.Now().Add(ttl),
71 }
72
73 return nil
74}
75
76func Clear(collection string, key interface{}) error {
77 lock.Lock()

Callers 15

describeServicesMethod · 0.92
describeStacksMethod · 0.92
describeStackEventsMethod · 0.92
describeStackResourceMethod · 0.92
listStackResourcesMethod · 0.92
describeTasksMethod · 0.92
taskReleaseMethod · 0.92
taskDefinitionReleaseMethod · 0.92

Calls 1

hashKeyFunction · 0.85

Tested by 5

TestSetFunction · 0.68
TestGetFunction · 0.68
TestGetExpiredDataFunction · 0.68
TestClearFunction · 0.68
TestClearPrefixFunction · 0.68