To delete the data inserted via txnkv API, you can:
db, _ := driver.Open("tikv://127.0.0.1:2379?disableGC=false")
txn, _ := db.Begin()
txn.Delete(key)
txn.Commit(context.Background())
...
Txnkv is based on MVCC, so Delete
will not reclaim disk space. Instead, it inserts a special version which indicates the key has been deleted.
If there is a TiDB in your cluster, and it enables GC, then the key will be deleted physically and automatically after a GC interval.
Otherwise you need to run GC job to delete it from disk.
import "github.com/pingcap/tidb/store/tikv/gcworker"
gcworker.RunGCJob(ctx context.Context, s tikv.Storage, safePoint uint64, identifier string, concurrency int)