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

Function SetKey

pkg/cache/cache.go:79–95  ·  view source on GitHub ↗
(cacheName string, key string, value string, expiration *time.Duration)

Source from the content-addressed store, hash-verified

77}
78
79func SetKey(cacheName string, key string, value string, expiration *time.Duration) error {
80 for i, name := range CacheNames {
81 if name == cacheName {
82 if expiration == nil {
83 expiration = &CacheConfig[i].TTL
84 }
85
86 CacheConfig[i].Logger.Debugf("Setting key %s to %s with expiration %v", key, value, *expiration)
87
88 if err := Caches[i].SetWithExpire(key, value, *expiration); err != nil {
89 CacheConfig[i].Logger.Warningf("While setting key %s in cache %s: %s", key, cacheName, err)
90 }
91 }
92 }
93
94 return nil
95}
96
97func GetKey(cacheName string, key string) (string, error) {
98 for i, name := range CacheNames {

Callers 3

ApplyMethod · 0.92
SetInStashFunction · 0.92
TestCreateSetGetFunction · 0.85

Calls

no outgoing calls

Tested by 1

TestCreateSetGetFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…