github.com/GeniusesGroup/libgo@v0.0.0-20220929090155-5ff932cb408e/protocol/storage-key-value.go (about) 1 /* For license and copyright information please see LEGAL file in repository */ 2 3 package protocol 4 5 // StorageKeyValue is the interface that show how an key-value directory work. 6 // If need encryption, Implement requirements at block storage level. 7 // https://github.com/cockroachdb/pebble/blob/master/open.go 8 type StorageKeyValue interface { 9 KeyNumbers() (num uint64, err Error) 10 ListKeys(offset, limit uint64) (keys [][]byte, err Error) 11 12 Lock(key []byte) (value []byte, err Error) 13 Unlock(key []byte, value []byte) (err Error) 14 15 Length(key []byte) (ln int, err Error) 16 Get(key []byte) (value []byte, err Error) 17 Set(key []byte, value []byte, options StorageKeyValue_SaveOptions) (err Error) 18 19 // make invisible just by remove from primary index 20 Delete(key []byte) (err Error) 21 // make invisible by remove from primary index & write zero data to value location 22 Erase(key []byte) (err Error) 23 24 // Multiple changes can be made in one atomic batch 25 // Batch() 26 } 27 28 type StorageKeyValue_SaveOptions struct { 29 // TTL(Time-To-Live) or Expiration Number of nanoseconds until record expires. 30 TTL Duration 31 }