https://github.com/nuts-foundation/go-stoabs
Pluggable storage for Go
https://github.com/nuts-foundation/go-stoabs
Last synced: 6 months ago
JSON representation
Pluggable storage for Go
- Host: GitHub
- URL: https://github.com/nuts-foundation/go-stoabs
- Owner: nuts-foundation
- License: gpl-3.0
- Created: 2022-05-23T10:42:37.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2025-08-28T11:27:13.000Z (11 months ago)
- Last Synced: 2025-08-28T18:39:19.150Z (11 months ago)
- Language: Go
- Size: 378 KB
- Stars: 0
- Watchers: 6
- Forks: 1
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- License: COPYING
Awesome Lists containing this project
README
# Golang Storage Abstraction (go-stoabs)
## BBolt
## Redis
When creating a Redis `KVStore` it tests the connection using Redis' `PING` command.
Due to the simple API of the library, the Redis adapter only supports reading/writing byte arrays.
The behavior when reading any other Redis type (e.g. a list or set) is undefined.
### Transaction Isolation
Redis doesn't have actual transactions, so this library simulates them by using the `MULTI`/`EXEC`/`DISCARD` commands.
That way all commands are guaranteed to be executed atomically.
As a consequence, a value that hasn't been committed yet can't be read. In other words, don't try to read a value from a
key that was written to in the same transaction.
Subsequently, changes from other writers (from the same process or remote) are reflected immediately in the current
transaction: if a key is read twice, there's no guarantee the returned value will be equal.
If the application requires exclusive write access to a store it can lock the database, to assert there are no other
active writers:
```golang
store.Write(func (tx stoabs.WriteTx) error {
// do something with tx
}, stoabs.WithWriteLock())
```
The lock is released when the transaction is committed or rolled back.
The lock is subject to the prefix (`CreateRedisStore(prefix string, ...)`) the store was created with, meaning other stores with the same prefix will have the same lock.
Redis locks are implemented using (Redsync)[https://github.com/go-redsync/redsync].
### Unsupported features
* Clustering