mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2024-11-27 03:58:06 +00:00
storage: don't use locks for memory batches
They're inherently single-threaded, so locking makes no sense for them.
This commit is contained in:
parent
0a2bbf3c04
commit
18682f2409
2 changed files with 4 additions and 3 deletions
|
@ -23,12 +23,12 @@ type MemoryBatch struct {
|
||||||
|
|
||||||
// Put implements the Batch interface.
|
// Put implements the Batch interface.
|
||||||
func (b *MemoryBatch) Put(k, v []byte) {
|
func (b *MemoryBatch) Put(k, v []byte) {
|
||||||
_ = b.MemoryStore.Put(k, v)
|
b.MemoryStore.put(string(k), slice.Copy(v))
|
||||||
}
|
}
|
||||||
|
|
||||||
// Delete implements Batch interface.
|
// Delete implements Batch interface.
|
||||||
func (b *MemoryBatch) Delete(k []byte) {
|
func (b *MemoryBatch) Delete(k []byte) {
|
||||||
_ = b.MemoryStore.Delete(k)
|
b.MemoryStore.drop(string(k))
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewMemoryStore creates a new MemoryStore object.
|
// NewMemoryStore creates a new MemoryStore object.
|
||||||
|
|
|
@ -52,7 +52,8 @@ type (
|
||||||
|
|
||||||
// Batch represents an abstraction on top of batch operations.
|
// Batch represents an abstraction on top of batch operations.
|
||||||
// Each Store implementation is responsible of casting a Batch
|
// Each Store implementation is responsible of casting a Batch
|
||||||
// to its appropriate type.
|
// to its appropriate type. Batches can only be used in a single
|
||||||
|
// thread.
|
||||||
Batch interface {
|
Batch interface {
|
||||||
Delete(k []byte)
|
Delete(k []byte)
|
||||||
Put(k, v []byte)
|
Put(k, v []byte)
|
||||||
|
|
Loading…
Reference in a new issue