Comments (6)
Similarly, if Bucket was a datatype that's actually useful for callers, and refcounted the buckets, one could use that to avoid the error on every call of .Cursor; the only source for error is bucket not existing.
from bolt.
I like the idea of adding bolt.Open()
. That'd be easy enough to add. Making Bucket
a useful type makes a lot of sense too. It'd be nice to do this without error checks:
b := txn.Bucket("foo")
value := b.Get([]byte("bar"))
I'm hesitant to defer ErrDatabaseNotOpen
errors to transaction operations. For example, if I know that bucket "widgets" exists in my database then I'll won't do a nil check after retrieving from a transaction. I can't do that if the transaction will fail and return nil for a closed database.
Ultimately I think most people will use the Do()
and With()
functions which combines transaction open and close errors together.
Thanks for taking such a deep dive into the code and poking around. It's great to get feedback like this!
from bolt.
I wrote that part before discovering Do() and With(). They look good, hopefully the closures won't cost too much.
from bolt.
@tv42 I'm a little worried about closure performance too but hopefully it won't be too bad. I'll add some closure vs non-closure benchmarks once I get to profiling.
from bolt.
@tv42 I'm going to move the data accessor and mutator functions from Transaction
and RWTransaction
to the Bucket
:
Cursor() *Cursor
Delete(key []byte) error
ForEach(fn func(k, v []byte) error) error
Get(key []byte) []byte
NextSequence() error
Put(key, value []byte) error
If accessors (e.g. Bucket.Get()
, Bucket.Cursor()
) are called after a Transaction
is closed should they panic? I think so.
I'm still going to keep those functions on DB
as ease-of-use functions.
I'll try to get to it this weekend but it may be early next week before I can do it.
from bolt.
Added bolt.Open()
in #53.
from bolt.
Related Issues (20)
- C/C++ binding for key/value storage HOT 3
- Security at rest HOT 1
- Can I use the same key for nested bucket and filed in a bucket/ HOT 1
- Document for New Contributors?
- page already freed HOT 5
- How to check if a file is a valid boltdb database without panicing HOT 2
- Check is a database open HOT 1
- what kind fo key can enhance write speed HOT 1
- concurrent writes and deadlocks HOT 2
- [RFE] change sequence number HOT 2
- [RFE] Database Generation ID HOT 7
- Database file size not updating after reaching 1GB HOT 3
- Meta2 make DBFile invalid HOT 1
- how to get the value that the current cursor points to HOT 3
- how to use boltdb for multiple files HOT 2
- page already freed on certain builds
- Not able to create subbucket inside loop
- Tons of compilation errors HOT 1
- permission denied in user home directory when open boltdb path HOT 1
- Cursor.Last() returns nil for non-empty bucket
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 bolt.