kv.go 1.4 KB

123456789101112131415161718192021222324252627282930313233
  1. package storage
  2. import "github.com/coreos/etcd/storage/storagepb"
  3. type KV interface {
  4. // Range gets the keys in the range at rangeIndex.
  5. // If rangeIndex <=0, range gets the keys at currentIndex.
  6. // If `end` is nil, the request returns the key.
  7. // If `end` is not nil, it gets the keys in range [key, range_end).
  8. // Limit limits the number of keys returned.
  9. Range(key, end []byte, limit, rangeIndex int64) (kvs []storagepb.KeyValue, index int64)
  10. // Put puts the given key,value into the store.
  11. // A put also increases the index of the store, and generates one event in the event history.
  12. Put(key, value []byte) (index int64)
  13. // DeleteRange deletes the given range from the store.
  14. // A deleteRange increases the index of the store if any key in the range exists.
  15. // The number of key deleted will be returned.
  16. // It also generates one event for each key delete in the event history.
  17. // if the `end` is nil, deleteRange deletes the key.
  18. // if the `end` is not nil, deleteRange deletes the keys in range [key, range_end).
  19. DeleteRange(key, end []byte) (n, index int64)
  20. // TnxBegin begins a tnx. Only Tnx prefixed operation can be executed, others will be blocked
  21. // until tnx ends. Only one on-going tnx is allowed.
  22. TnxBegin()
  23. // TnxEnd ends the on-going tnx.
  24. TnxEnd()
  25. TnxRange(key, end []byte, limit, rangeIndex int64) (kvs []storagepb.KeyValue, index int64)
  26. TnxPut(key, value []byte) (index int64)
  27. TnxDeleteRange(key, end []byte) (n, index int64)
  28. }