Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/akyoto/cache
:handbag: Cache arbitrary data with an expiration time.
https://github.com/akyoto/cache
cache go
Last synced: 5 days ago
JSON representation
:handbag: Cache arbitrary data with an expiration time.
- Host: GitHub
- URL: https://github.com/akyoto/cache
- Owner: akyoto
- License: mit
- Created: 2019-05-11T12:42:45.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2022-11-20T10:03:19.000Z (about 2 years ago)
- Last Synced: 2024-11-24T18:12:52.566Z (28 days ago)
- Topics: cache, go
- Language: Go
- Homepage:
- Size: 20.5 KB
- Stars: 186
- Watchers: 5
- Forks: 22
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-go - cache - In-memory key:value store with expiration time, 0 dependencies, <100 LoC, 100% coverage. (Database / Caches)
- awesome-go-extra - cache - 05-11T12:42:45Z|2022-08-10T02:39:09Z| (Generators / Caches)
README
# cache
[![Godoc][godoc-image]][godoc-url]
[![Report][report-image]][report-url]
[![Tests][tests-image]][tests-url]
[![Coverage][coverage-image]][coverage-url]
[![Sponsor][sponsor-image]][sponsor-url]Cache arbitrary data with an expiration time.
## Features
* 0 dependencies
* About 100 lines of code
* 100% test coverage## Usage
```go
// New cache
c := cache.New(5 * time.Minute)// Put something into the cache
c.Set("a", "b", 1 * time.Minute)// Read from the cache
obj, found := c.Get("a")// Convert the type
fmt.Println(obj.(string))
```## Benchmarks
```text
BenchmarkGet-12 300000000 3.88 ns/op 0 B/op 0 allocs/op
BenchmarkSet-12 10000000 183 ns/op 48 B/op 2 allocs/op
BenchmarkNew-12 10000000 112 ns/op 352 B/op 5 allocs/op
```## Style
Please take a look at the [style guidelines](https://github.com/akyoto/quality/blob/master/STYLE.md) if you'd like to make a pull request.
## Sponsors
| [![Cedric Fung](https://avatars3.githubusercontent.com/u/2269238?s=70&v=4)](https://github.com/cedricfung) | [![Scott Rayapoullé](https://avatars3.githubusercontent.com/u/11772084?s=70&v=4)](https://github.com/soulcramer) | [![Eduard Urbach](https://avatars3.githubusercontent.com/u/438936?s=70&v=4)](https://eduardurbach.com) |
| --- | --- | --- |
| [Cedric Fung](https://github.com/cedricfung) | [Scott Rayapoullé](https://github.com/soulcramer) | [Eduard Urbach](https://eduardurbach.com) |Want to see [your own name here?](https://github.com/users/akyoto/sponsorship)
[godoc-image]: https://godoc.org/github.com/akyoto/cache?status.svg
[godoc-url]: https://godoc.org/github.com/akyoto/cache
[report-image]: https://goreportcard.com/badge/github.com/akyoto/cache
[report-url]: https://goreportcard.com/report/github.com/akyoto/cache
[tests-image]: https://cloud.drone.io/api/badges/akyoto/cache/status.svg
[tests-url]: https://cloud.drone.io/akyoto/cache
[coverage-image]: https://codecov.io/gh/akyoto/cache/graph/badge.svg
[coverage-url]: https://codecov.io/gh/akyoto/cache
[sponsor-image]: https://img.shields.io/badge/github-donate-green.svg
[sponsor-url]: https://github.com/users/akyoto/sponsorship