diff --git a/README.md b/README.md new file mode 100644 index 0000000..160dc52 --- /dev/null +++ b/README.md @@ -0,0 +1,21 @@ +# ezcache + +ezcache is a simple in-memory cache for golang that has data expiry. + +## Usage + +```go +import "codeberg.org/danjones000/ezcache" + +// ... + +// Create a user cache which will cache users for five minutes +userCache := ezcache.New(func(id uint64) (User, error) { + // logic to fetch user from database + return User{}, nil +}, 5 * time.Minute) + +user, err := user.Get(userID) +// Next time you do user.Get with the same userID within five minutes, it will be fetched from cache. +// After five minutes, it will fetch from the database again. +```