Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/makigas/redismemo
Package redismemo provides a basic memoization system around Redis.
https://github.com/makigas/redismemo
cache go-redis golang memoization redis
Last synced: about 1 month ago
JSON representation
Package redismemo provides a basic memoization system around Redis.
- Host: GitHub
- URL: https://github.com/makigas/redismemo
- Owner: makigas
- License: other
- Created: 2023-08-05T11:56:08.000Z (over 1 year ago)
- Default Branch: trunk
- Last Pushed: 2023-08-05T11:56:32.000Z (over 1 year ago)
- Last Synced: 2023-12-04T23:40:19.797Z (about 1 year ago)
- Topics: cache, go-redis, golang, memoization, redis
- Language: Go
- Homepage: https://gopkg.makigas.es/redismemo
- Size: 3.91 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README
- License: LICENSE.txt
Awesome Lists containing this project
README
package redismemo // import "gopkg.makigas.es/redismemo"
Package redismemo provides a basic memoization system around Redis.
It works by wrapping a go-redis/v9 client and providing a simple function that
can be used to fetch a value from Redis given its key, as well as the compute
function to be issued if the value is not found in the Redis instance. If the
value has to be computed, it is also set in the Redis instance using the given
TTL, which comes handy for caches.TYPES
type Compute func() string
Compute is a lazy function that when evaluated returns a string value.
Computes are used as a fallback if the cache does not hold the given key.type Memo func(ctx context.Context, key string, value Compute, exp time.Duration) (string, error)
Memo is a function that memoizes values in a cache. Memo returns the string
identified by the given cache key. If the cache does not hold the key,
it computes the value and stores it with the given expiration TTL.func RedisMemo(rdb *redis.Client) Memo
RedisMemo wraps a Redis client to provide a memoization function.