Giter VIP home page Giter VIP logo

go-stoabs's Introduction

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:

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

go-stoabs's People

Contributors

reinkrul avatar dependabot[bot] avatar woutslakhorst avatar gerardsn avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.