Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/nowayhecodes/polacache
A deadly simple and thread-safe map cache
https://github.com/nowayhecodes/polacache
cache-storage caching channels concurrent go go-channel golang goroutine thread-safe
Last synced: about 2 months ago
JSON representation
A deadly simple and thread-safe map cache
- Host: GitHub
- URL: https://github.com/nowayhecodes/polacache
- Owner: nowayhecodes
- License: mit
- Created: 2022-08-02T01:21:11.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2022-08-14T03:34:22.000Z (over 2 years ago)
- Last Synced: 2024-06-20T14:17:24.807Z (7 months ago)
- Topics: cache-storage, caching, channels, concurrent, go, go-channel, golang, goroutine, thread-safe
- Language: Go
- Homepage:
- Size: 307 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Polacache
A deadly simple and thread-safe map cache.
#### What?
Polacache is a deadly simple and thread-safe map cache.
In it's constructor, you set a cleanupInterval, which launchs a goroutine to perform the cleanup loop.#### Why?
For the fun
#### How?
```go
package main
import (
"time"
pc "github.com/nowayhecodes/polacache"
)func main() {
cache := pc.New(1 * time.Minute)exampleItem := pc.Item{
Key: "example",
Value: 42,
}cache.Set(exampleItem, time.Now().Add(1*time.Hour).Unix())
cache.Get(exampleItem.Key)
cache.Delete(exampleItem.Key)}
```