Преглед на файлове

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>
Cory Snider преди 1 година
родител
ревизия
4af420f978
променени са 3 файла, в които са добавени 0 реда и са изтрити 51 реда
  1. 0 10
      libnetwork/datastore/mockstore_test.go
  2. 0 38
      libnetwork/internal/kvstore/boltdb/boltdb.go
  3. 0 3
      libnetwork/internal/kvstore/kvstore.go

+ 0 - 10
libnetwork/datastore/mockstore_test.go

@@ -23,16 +23,6 @@ func NewMockStore() *MockStore {
 	return &MockStore{db: make(map[string]*MockData)}
 	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"
 // Put a value at "key"
 func (s *MockStore) Put(key string, value []byte) error {
 func (s *MockStore) Put(key string, value []byte) error {
 	mData := s.db[key]
 	mData := s.db[key]

+ 0 - 38
libnetwork/internal/kvstore/boltdb/boltdb.go

@@ -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
 // Put the key, value pair. index number metadata is prepended to the value
 func (b *BoltDB) Put(key string, value []byte) error {
 func (b *BoltDB) Put(key string, value []byte) error {
 	b.mu.Lock()
 	b.mu.Lock()

+ 0 - 3
libnetwork/internal/kvstore/kvstore.go

@@ -39,9 +39,6 @@ type Store interface {
 	// Put a value at the specified key
 	// Put a value at the specified key
 	Put(key string, value []byte) error
 	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 verifies if a Key exists in the store.
 	Exists(key string) (bool, error)
 	Exists(key string) (bool, error)