karlseguin / ccache

A golang LRU Cache for high concurrency
MIT License
1.27k stars 118 forks source link

Added Key() method to Item #84

Closed idsulik closed 9 months ago

idsulik commented 9 months 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)))
                }
            }
        },
    ),
)