Skip to content
/ cache Public

In-memory cache Go module. No locks, integrated statistics.

License

Notifications You must be signed in to change notification settings

golift/cache

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

38 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

cache

GoDoc Go Report Card MIT License discord

This go module provides a very simple in-memory key/value cache. It uses 1 mutex lock only during start and stop; utilizes only 1 go routine, 2 channels, and 1 or 2 tickers depending on if you enable the pruner. The module also exports git/miss statistics that you can plug into expvar, or other metrics modules.

This module has a concept of pruning. Items can be marked prunable, or not prunable. Those marked prunable are deleted after they have not had a get request within a specified duration. Those marked not-prunable have a different configurable maximum unused age.

I wrote this to cache data from mysql queries for an nginx auth proxy. I've since began using it in plenty of other places as a global data store. See a simple example in cache_test.go.