MCPcopy
hub / github.com/crowdsecurity/crowdsec / GetKey

Function GetKey

pkg/cache/cache.go:97–118  ·  view source on GitHub ↗
(cacheName string, key string)

Source from the content-addressed store, hash-verified

95}
96
97func GetKey(cacheName string, key string) (string, error) {
98 for i, name := range CacheNames {
99 if name == cacheName {
100 value, err := Caches[i].Get(key)
101 if err != nil {
102 // do not warn or log if key not found
103 if errors.Is(err, gcache.KeyNotFoundError) {
104 return "", nil
105 }
106 CacheConfig[i].Logger.Warningf("While getting key %s in cache %s: %s", key, cacheName, err)
107
108 return "", err
109 }
110
111 return value.(string), nil
112 }
113 }
114
115 log.Warningf("Cache %s not found", cacheName)
116
117 return "", nil
118}

Callers 2

GetFromStashFunction · 0.92
TestCreateSetGetFunction · 0.85

Calls 1

GetMethod · 0.45

Tested by 1

TestCreateSetGetFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…