https://github.com/streamdp/microcache
Just a simple implementation of an in-memory cache with entry expiration
https://github.com/streamdp/microcache
Last synced: 23 days ago
JSON representation
Just a simple implementation of an in-memory cache with entry expiration
- Host: GitHub
- URL: https://github.com/streamdp/microcache
- Owner: streamdp
- License: apache-2.0
- Created: 2025-01-20T06:48:51.000Z (3 months ago)
- Default Branch: main
- Last Pushed: 2025-03-25T15:50:08.000Z (about 1 month ago)
- Last Synced: 2025-04-12T15:13:53.988Z (23 days ago)
- Language: Go
- Size: 17.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
## Microcache
Just a simple implementation of an in-memory cache with entry expiration### Usage
You can use it directly:
```go
package mainimport (
"context"
"fmt"
"time""github.com/streamdp/microcache"
)func main() {
cache := microcache.New(context.Background(), 0)
_ = cache.Set("key1", "val1", time.Hour)fmt.Println(cache.Get("key1"))
}
```
Or create your own cache based on this solution, microCache implements the following interface:
```go
type Cache interface {
Get(key string) (any, error)
Set(key string, value any, expiration time.Duration) error
}
```
Look at the examples folder for explanations.