Browse Source

libnetwork/internal/kvstore: remove unused Delete()

All code is using the atomic alternatives (AtomicDelete)

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Sebastiaan van Stijn 2 năm trước cách đây
mục cha
commit
4c4149a09c

+ 2 - 7
libnetwork/datastore/mock_store.go

@@ -48,12 +48,6 @@ func (s *MockStore) Put(key string, value []byte) error {
 	return nil
 	return nil
 }
 }
 
 
-// Delete a value at "key"
-func (s *MockStore) Delete(key string) error {
-	delete(s.db, key)
-	return nil
-}
-
 // Exists checks that the key exists inside the store
 // Exists checks that the key exists inside the store
 func (s *MockStore) Exists(key string) (bool, error) {
 func (s *MockStore) Exists(key string) (bool, error) {
 	_, ok := s.db[key]
 	_, ok := s.db[key]
@@ -95,7 +89,8 @@ func (s *MockStore) AtomicDelete(key string, previous *store.KVPair) error {
 	if mData != nil && mData.Index != previous.LastIndex {
 	if mData != nil && mData.Index != previous.LastIndex {
 		return types.BadRequestErrorf("atomic delete failed due to mismatched Index")
 		return types.BadRequestErrorf("atomic delete failed due to mismatched Index")
 	}
 	}
-	return s.Delete(key)
+	delete(s.db, key)
+	return nil
 }
 }
 
 
 // Close closes the client connection
 // Close closes the client connection

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

@@ -178,26 +178,6 @@ func (b *BoltDB) Put(key string, value []byte) error {
 	})
 	})
 }
 }
 
 
-// Delete the value for the given key.
-func (b *BoltDB) Delete(key string) error {
-	b.mu.Lock()
-	defer b.mu.Unlock()
-
-	db, err := b.getDBhandle()
-	if err != nil {
-		return err
-	}
-	defer b.releaseDBhandle()
-
-	return db.Update(func(tx *bolt.Tx) error {
-		bucket := tx.Bucket(b.boltBucket)
-		if bucket == nil {
-			return store.ErrKeyNotFound
-		}
-		return bucket.Delete([]byte(key))
-	})
-}
-
 // Exists checks if the key exists inside the store
 // Exists checks if the key exists inside the store
 func (b *BoltDB) Exists(key string) (bool, error) {
 func (b *BoltDB) Exists(key string) (bool, error) {
 	b.mu.Lock()
 	b.mu.Lock()

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

@@ -42,9 +42,6 @@ type Store interface {
 	// Get a value given its key
 	// Get a value given its key
 	Get(key string) (*KVPair, error)
 	Get(key string) (*KVPair, error)
 
 
-	// Delete the value at the specified key
-	Delete(key string) 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)