Comments (3)
Hey! Yes I meant to say that the bbolt batch method could call the underlying bbolt batch method as I had linked earlier.
Not all of the databases that have a gokv.Store implementation support batch operations natively. For other DBs you could implement a convenience method that then calls the single Set method multiple times for all elements of the slice, but then what about databases that don't support transactions? You could ignore transactions and just call Set multiple times, but the method caller (package user) might expect an atomic transaction for each SetBatch call.
Yes precisely this. Where it makes sense, the implementation will call the batch operation for that datastore. Where it doesn't, we could invoke Set multiple times, or better and more safer, not have it implemented and leave the decision on the user to decide if they wanted to implement it themselves (by wrapping regular Set in a loop, interface embedding and extending it, etc.)
from gokv.
Hi! Sorry for the late reply!
Do you mean something exactly like the bbolt Batch method you linked to, where the docs say:
Batch is only useful when there are multiple goroutines calling it.
Or do you mean batch methods in general, where you can set/delete multiple values within a single transaction, so the required gokv.Store
method would looke something like SetBatch(key string, values ...interface{}) error
(with values
being variadic) or similar?
Method signature options could then be (for this latter understanding of what you mean with batch):
package main
import (
"fmt"
)
func main() {
fmt.Println("Hello, playground")
key := "k"
setBatch1(key, 1, "2")
vals := make([]interface{}, 2)
vals[0] = 1
vals[1] = "2"
setBatch2(key, vals)
setBatch3(key, vals)
}
func setBatch1(key string, values ...interface{}) {
fmt.Printf("values[0]: %v (%T); values[1]: %v (%T)\n", values[0], values[0], values[1], values[1])
}
func setBatch2(key string, values []interface{}) {
fmt.Printf("values[0]: %v (%T); values[1]: %v (%T)\n", values[0], values[0], values[1], values[1])
}
func setBatch3(key string, values interface{}) {
vals, ok := values.([]interface{})
if !ok {
panic("nok")
}
fmt.Printf("values[0]: %v (%T); values[1]: %v (%T)\n", vals[0], vals[0], vals[1], vals[1])
}
(https://play.golang.org/p/HlOR1I6P81f)
But:
Not all of the databases that have a gokv.Store
implementation support batch operations natively. For other DBs you could implement a convenience method that then calls the single Set method multiple times for all elements of the slice, but then what about databases that don't support transactions? You could ignore transactions and just call Set multiple times, but the method caller (package user) might expect an atomic transaction for each SetBatch call.
What do you think?
from gokv.
for atomicity, we can take a mutex... and then call loop of sets... no ?
obviously, only applicable if called from the same app...
from gokv.
Related Issues (20)
- Is this project active? HOT 23
- can support `incr` 、`decr` and `keys` HOT 1
- Expose more features in the Hazelcast client
- S3: don't require attempt to create bucket in s3.NewClient
- encoding: add support for PB (Protocol Buffers)
- redis: add opentelemtry.io instrumentation HOT 1
- redis: update to v9
- ci: add windows and macos HOT 2
- Connection string for all storage HOT 1
- check if the context was already canceled
- Add `timeout` to all store configs and use it in Context
- Add `GetClient` method to all implementations
- Add implementation for Pudge HOT 2
- Add gokv.Store implementation for BuntDB HOT 1
- Support Go modules
- Add more gokv.Store implementations HOT 5
- The BigCache concurrency test is flaky
- Expiration by time HOT 2
- Sync() for persistent KV stores.
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gokv.