An open API service indexing awesome lists of open source software.

https://github.com/topfreegames/go-extensions-redis


https://github.com/topfreegames/go-extensions-redis

Last synced: 7 months ago
JSON representation

Awesome Lists containing this project

README

          

# go-extensions-redis

This library provides interfaces and implementations for Redis clients and multiplexers. It also
has a very tight relationship with [go-redis](https://github.com/go-redis/redis) in order to reuse
it's signatures and return types.

Clients interfaces are `Client` and `LockerClient`. The last one guarantees that implementers are
both `Client` and `Locker`.

`Locker` implementers must expose functions to lock access to keys, in order to prevent race
conditions. The implementation provided, `BaseClient`, is for a `LockerClient`.

`Mux` is an interface implemented by `BaseMux`. It's purpose is to use multiple redis instances as
shards where operations over a key consistently happen in the same instance during a time interval
either set through a TTL or manually invalidated by calling `Invalidate(Hash) error` present in
`Mux`.

`BaseMux` mappings are also stored and retrieved through a redis client.

`BaseClient` and `BaseMux` have open-tracing support and provide `WithContext(context.Context)`
methods.

## Contribution

If any changes are made to interfaces and/or new interfaces are added, check `make mocks` command
and run it.

## TODO:

- [ ] Tests
- [X] BaseMux implements Mux?
- [X] BaseClient implements Client?
- [ ] Tracing
- [X] ErrClient
- [X] Mocks
- [X] Docs
- [ ] ErrClient Pipeliner?