MCPcopy Create free account
hub / github.com/ContentSquare/chproxy / nbOfBytes

Method nbOfBytes

cache/redis_cache.go:76–95  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

74}
75
76func (r *redisCache) nbOfBytes() uint64 {
77 ctx, cancelFunc := context.WithTimeout(context.Background(), statsTimeout)
78 defer cancelFunc()
79 memoryInfo, err := r.client.Info(ctx, "memory").Result()
80 if err != nil {
81 log.Errorf("failed to fetch nb of bytes in redis: %s", err)
82 }
83 matches := usedMemoryRegexp.FindStringSubmatch(memoryInfo)
84
85 var cacheSize int
86
87 if len(matches) > 1 {
88 cacheSize, err = strconv.Atoi(matches[1])
89 if err != nil {
90 log.Errorf("failed to parse memory usage with error %s", err)
91 }
92 }
93
94 return uint64(cacheSize)
95}
96
97func (r *redisCache) Get(key *Key) (*CachedData, error) {
98 ctx, cancelFunc := context.WithTimeout(context.Background(), getTimeout)

Callers 2

StatsMethod · 0.95
TestCacheSizeFunction · 0.80

Calls 1

ErrorfFunction · 0.92

Tested by 1

TestCacheSizeFunction · 0.64