Skip to content

WeiJiadong/gocache

Repository files navigation

gocache

Badge Go Go Report Card GoDoc Latest codecov License

支持的功能

1.并发安全;
2.LRU淘汰策略;
3.数据过期,过期策略为懒更新;
4.value支持interface;
5.支持返回过期数据和对应error;
6.支持singelfight方式更新下游;
7.支持一键式读取并更新缓存;
8.支持缓存状态信息打印。

使用示例

func main() {
    cache := NewGoCacheBuilder(WithExpire(time.Second), WithKeyCnt(3), WithName("test_cache"))
    v, err := cache.Get(context.TODO(), "1", func() (interface{}, error) {
        return "1", nil
    })
}

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages