weixin_39690958
weixin_39690958
2020-11-30 00:09

Add disk based cache system

I added the package "cache/file" that support a disk based cache system. With low memory environment the disk based cache system is useful.

Usage (part of examples/cache):


var flagFile     = "/tmp"

// part of examples/cache/cache.go
func newServerFile(srv imageserver.Server) imageserver.Server {
    if flagFile == "" {
        return srv
    }
    cch := imageserver_cache_file.Cache{flagFile }
    kg := imageserver_cache.NewParamsHashKeyGenerator(sha256.New)
    return &imageserver_cache.Server{
        Server:       srv,
        Cache:        &cch,
        KeyGenerator: kg,
    }
}

该提问来源于开源项目:pierrre/imageserver

  • 点赞
  • 回答
  • 收藏
  • 复制链接分享

5条回答