MCPcopy
hub / github.com/convox/rack / Get

Function Get

pkg/cache/cache.go:23–52  ·  view source on GitHub ↗
(collection string, key interface{})

Source from the content-addressed store, hash-verified

21)
22
23func Get(collection string, key interface{}) interface{} {
24 lock.Lock()
25 defer lock.Unlock()
26
27 if os.Getenv("PROVIDER") == "test" {
28 return nil
29 }
30
31 hash, err := hashKey(key)
32
33 if err != nil {
34 return nil
35 }
36
37 if cache[collection] == nil {
38 return nil
39 }
40
41 item := cache[collection][hash]
42
43 if item == nil {
44 return nil
45 }
46
47 if item.Expires.Before(time.Now()) {
48 return nil
49 }
50
51 return item.Item
52}
53
54func Set(collection string, key, value interface{}, ttl time.Duration) error {
55 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 4

TestGetFunction · 0.56
TestGetExpiredDataFunction · 0.56
TestClearFunction · 0.56
TestClearPrefixFunction · 0.56