-
Notifications
You must be signed in to change notification settings - Fork 229
RawKV Basic
If you don't need transaction and multi-version support, you can consider using TiKV in the rawkv way, which usually has a faster response time.
Note: Currently a TiKV cluster can only choose one of the rawkv or txnkv APIs to use. Mixing them will cause unavailability issues due to inconsistent key encoding.
The simple usage of rawkv can be found in example usage.
By using CAS, we can guarantee that the value is written only when the old value is equal to the provided one.
Note: To use CAS, you must set client.SetAtomicForCAS(true)
for all the clients before you use them. If there are some clients in the cluster that are not set up correctly, it may break the CAS constraints.
You can specify the time it survives in seconds when you put the key-value pair. After the time is exceeded, TiKV will automatically clear the corresponding data, or at least ensure that it will return null when queried - as if the data did not exist.
Note that the TTL cleanup depends on the local clock of the tikv-server. It is necessary to ensure the accuracy of the clock by means of NTP etc.
GetKeyTTL
can be used to query the TTL of a key. The returned value is the left seconds of the TTL. If the key does not exist, it returns nil. If the key exists but has no TTL, it returns 0.
Feel free to help improving! Minor changes are warmly welcomed. Just simply click edit!
This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.
Contents
- Client-Go Wiki
- Compatibility
- API V2
- Transactional API
- RawKV API
- Configurations
- Utilities