github.com/igggame/nebulas-go@v2.1.0+incompatible/storage/types.go (about) 1 // Copyright (C) 2017 go-nebulas authors 2 // 3 // This file is part of the go-nebulas library. 4 // 5 // the go-nebulas library is free software: you can redistribute it and/or modify 6 // it under the terms of the GNU General Public License as published by 7 // the Free Software Foundation, either version 3 of the License, or 8 // (at your option) any later version. 9 // 10 // the go-nebulas library is distributed in the hope that it will be useful, 11 // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 // GNU General Public License for more details. 14 // 15 // You should have received a copy of the GNU General Public License 16 // along with the go-nebulas library. If not, see <http://www.gnu.org/licenses/>. 17 // 18 19 package storage 20 21 import "errors" 22 23 // const 24 var ( 25 ErrKeyNotFound = errors.New("not found") 26 ) 27 28 // Storage interface of Storage. 29 type Storage interface { 30 // Get return the value to the key in Storage. 31 Get(key []byte) ([]byte, error) 32 33 // Put put the key-value entry to Storage. 34 Put(key []byte, value []byte) error 35 36 // Del delete the key entry in Storage. 37 Del(key []byte) error 38 39 // EnableBatch enable batch write. 40 EnableBatch() 41 42 // DisableBatch disable batch write. 43 DisableBatch() 44 45 // Flush write and flush pending batch write. 46 Flush() error 47 }