@Override
    public void compareAndPut(final byte[] key, final byte[] expect, final byte[] update, final KVStoreClosure closure) {
        final Timer.Context timeCtx = getTimeContext("COMPARE_PUT");
        final Lock readLock = this.readWriteLock.readLock();
        readLock.lock();
        try {
            final byte[] actual = this.db.get(key);
            if (Arrays.equals(expect, actual)) {
                if (update == null) {
                    this.db.delete(this.writeOptions, key);
                } else {
                    this.db.put(this.writeOptions, key, update);
                }
                setSuccess(closure, Boolean.TRUE);
            } else {
                setSuccess(closure, Boolean.FALSE);
            }
        } catch (final Exception e) {
            LOG.error("Fail to [COMPARE_PUT], [{}, {}, {}], {}.", BytesUtil.toHex(key), BytesUtil.toHex(expect),
                BytesUtil.toHex(update), StackTraceUtil.stackTrace(e));
            setCriticalError(closure, "Fail to [COMPARE_PUT]", e);
        } finally {
            readLock.unlock();
            timeCtx.stop();
        }
    }
Local KV store based on RocksDB

@author dennis
@author jiachun.fjc
jraft-rheakv/rheakv-core/src/main/java/com/alipay/sofa/jraft/rhea/storage/RocksRawKVStore.java