MCPcopy Index your code
hub / github.com/apache/answer / setCache

Method setCache

plugin/kv_storage.go:102–116  ·  view source on GitHub ↗
(ctx context.Context, params KVParams)

Source from the content-addressed store, hash-verified

100}
101
102func (kv *KVOperator) setCache(ctx context.Context, params KVParams) {
103 if kv.cacheTTL < 0 {
104 return
105 }
106
107 ttl := kv.cacheTTL
108 if ttl > 10 {
109 ttl += time.Duration(float64(ttl) * 0.1 * (1 - rand.Float64()))
110 }
111
112 cacheKey := kv.getCacheKey(params)
113 if err := kv.data.Cache.SetString(ctx, cacheKey, params.Value, ttl); err != nil {
114 log.Warnf("cache set failed: %v, key: %s", err, cacheKey)
115 }
116}
117
118func (kv *KVOperator) getCache(ctx context.Context, params KVParams) (string, bool, error) {
119 if kv.cacheTTL < 0 {

Callers 1

GetMethod · 0.95

Calls 2

getCacheKeyMethod · 0.95
SetStringMethod · 0.80

Tested by

no test coverage detected