go-redis / cache

Cache library with Redis backend for Golang
https://redis.uptrace.dev/guide/go-redis-cache.html
BSD 2-Clause "Simplified" License
757 stars 95 forks source link

Add cache hit field in Item #80

Open zacscoding opened 2 years ago

zacscoding commented 2 years ago

Add cache hit field in Item.

Hello :) I want to record cache metrics with labels when calling Once function like below

    item := &Item{}
    if err := cache.Once(item); err != nil {
        return err
    }

    metrics.IncCacheTotal("product")
    if item.CacheHit {
        metrics.IncCacheHit("product")
    }

I found Stats() function but this function provides only total count of hits and misses :(