Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/nxy7/dbcache
https://github.com/nxy7/dbcache
Last synced: 10 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/nxy7/dbcache
- Owner: nxy7
- Created: 2024-01-19T18:30:02.000Z (12 months ago)
- Default Branch: master
- Last Pushed: 2024-01-22T15:58:04.000Z (12 months ago)
- Last Synced: 2024-12-23T00:54:39.137Z (17 days ago)
- Language: Go
- Size: 21.5 KB
- Stars: 0
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Take home assignment
This library provides generic implementation of `Cache[T]` which can be accessed concurrently and is guaranteed to make at most
one call to underlying data source for any given key.To function correctly this cache requires `DataSource[T]` that implements `Get(key string) (*T, error)`.
## How to run tests
Tests can be run either with `go test . -race` or if nix is installed `nix develop . -c bash -c "go test . -race"`. Second approach would
automatically install and use pinned Go version.### Things to note
- tests can be a little flaky for huge amounts of concurrent requests (as far as I'm aware that's because of machine running out of RAM)
- this library caches keys indefinitely right now, but it's quite easy to add cache invalidation scheme