karlseguin / ccache

A golang LRU Cache for high concurrency
MIT License
1.31k stars 121 forks source link

Added Key() method to Item #84

Closed idsulik closed 1 year ago

idsulik commented 1 year ago

I need it in order to use check it OnDelete. Example:

ccache.New(
    ccache.Configure().MaxSize(1000).OnDelete(
        func(item *ccache.Item) {
            if util.IsFileCacheKey(item.Key()) {
                if err := os.Remove(item.Value().(string)); err != nil {
                    logger.Error("Can't remove file", zap.Error(err), zap.String("file", item.Value().(string)))
                }
            }
        },
    ),
)