libnetwork/internal/kvstore: prune unused method
The datastore never calls Get() due to how the cache is implemented. Signed-off-by: Cory Snider <csnider@mirantis.com>
This commit is contained in:
parent
4039b9c9c4
commit
4af420f978
3 changed files with 0 additions and 51 deletions
|
@ -23,16 +23,6 @@ func NewMockStore() *MockStore {
|
|||
return &MockStore{db: make(map[string]*MockData)}
|
||||
}
|
||||
|
||||
// Get the value at "key", returns the last modified index
|
||||
// to use in conjunction to CAS calls
|
||||
func (s *MockStore) Get(key string) (*store.KVPair, error) {
|
||||
mData := s.db[key]
|
||||
if mData == nil {
|
||||
return nil, nil
|
||||
}
|
||||
return &store.KVPair{Value: mData.Data, LastIndex: mData.Index}, nil
|
||||
}
|
||||
|
||||
// Put a value at "key"
|
||||
func (s *MockStore) Put(key string, value []byte) error {
|
||||
mData := s.db[key]
|
||||
|
|
|
@ -109,44 +109,6 @@ func (b *BoltDB) releaseDBhandle() {
|
|||
}
|
||||
}
|
||||
|
||||
// Get the value at "key". BoltDB doesn't provide an inbuilt last modified index with every kv pair. Its implemented by
|
||||
// by a atomic counter maintained by the libkv and appened to the value passed by the client.
|
||||
func (b *BoltDB) Get(key string) (*store.KVPair, error) {
|
||||
b.mu.Lock()
|
||||
defer b.mu.Unlock()
|
||||
|
||||
db, err := b.getDBhandle()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer b.releaseDBhandle()
|
||||
|
||||
var val []byte
|
||||
err = db.View(func(tx *bolt.Tx) error {
|
||||
bucket := tx.Bucket(b.boltBucket)
|
||||
if bucket == nil {
|
||||
return store.ErrKeyNotFound
|
||||
}
|
||||
|
||||
v := bucket.Get([]byte(key))
|
||||
val = make([]byte, len(v))
|
||||
copy(val, v)
|
||||
|
||||
return nil
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if len(val) == 0 {
|
||||
return nil, store.ErrKeyNotFound
|
||||
}
|
||||
|
||||
dbIndex := binary.LittleEndian.Uint64(val[:libkvmetadatalen])
|
||||
val = val[libkvmetadatalen:]
|
||||
|
||||
return &store.KVPair{Key: key, Value: val, LastIndex: dbIndex}, nil
|
||||
}
|
||||
|
||||
// Put the key, value pair. index number metadata is prepended to the value
|
||||
func (b *BoltDB) Put(key string, value []byte) error {
|
||||
b.mu.Lock()
|
||||
|
|
|
@ -39,9 +39,6 @@ type Store interface {
|
|||
// Put a value at the specified key
|
||||
Put(key string, value []byte) error
|
||||
|
||||
// Get a value given its key
|
||||
Get(key string) (*KVPair, error)
|
||||
|
||||
// Exists verifies if a Key exists in the store.
|
||||
Exists(key string) (bool, error)
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue