From c47ab5eeedfffa7c446beb9db0b3ac79944095e3 Mon Sep 17 00:00:00 2001 From: chejinge Date: Wed, 11 Oct 2023 15:51:46 +0800 Subject: [PATCH] fix --- src/dory/include/build_version.h | 2 +- src/dory/src/RedisBit.cc | 23 ++++--------- src/dory/src/RedisCache.cc | 42 +++++++++--------------- src/dory/src/RedisHash.cc | 44 +++++++++---------------- src/dory/src/RedisList.cc | 41 ++++++++--------------- src/dory/src/RedisSet.cc | 20 ++++-------- src/dory/src/RedisString.cc | 50 ++++++++++------------------ src/dory/src/RedisZset.cc | 56 +++++++++++--------------------- src/pika_cache.cc | 18 ---------- 9 files changed, 96 insertions(+), 200 deletions(-) diff --git a/src/dory/include/build_version.h b/src/dory/include/build_version.h index 40ca499dbc..2c3f3ffdc2 100644 --- a/src/dory/include/build_version.h +++ b/src/dory/include/build_version.h @@ -1,4 +1,4 @@ -// Copyright (c) 2017-present The dory Authors. All rights reserved. +// Copyright (c) 2023-present The dory Authors. All rights reserved. // This source code is licensed under the BSD-style license found in the // LICENSE file in the root directory of this source tree. An additional grant // of patent rights can be found in the PATENTS file in the same directory. diff --git a/src/dory/src/RedisBit.cc b/src/dory/src/RedisBit.cc index 14f0a6c812..00aebd3cdd 100644 --- a/src/dory/src/RedisBit.cc +++ b/src/dory/src/RedisBit.cc @@ -1,12 +1,8 @@ -#include "RedisCache.h" -#include "pstd_status.h" -#include "redisdb/object.h" +#include "dory/include/RedisCache.h" namespace dory { -using rocksdb::Status; -Status -RedisCache::SetBit(std::string &key, size_t offset, long value) +Status RedisCache::SetBit(std::string &key, size_t offset, long value) { if (C_OK != RsFreeMemoryIfNeeded(m_RedisDB)) { return Status::Corruption("[error] Free memory faild !"); @@ -22,8 +18,7 @@ RedisCache::SetBit(std::string &key, size_t offset, long value) return Status::OK(); } -Status -RedisCache::GetBit(std::string &key, size_t offset, long *value) +Status RedisCache::GetBit(std::string &key, size_t offset, long *value) { int ret; robj *kobj = createObject(OBJ_STRING, sdsnewlen(key.data(), key.size())); @@ -41,8 +36,7 @@ RedisCache::GetBit(std::string &key, size_t offset, long *value) return Status::OK(); } -Status -RedisCache::BitCount(std::string &key, long start, long end, long *value, bool have_offset) +Status RedisCache::BitCount(std::string &key, long start, long end, long *value, bool have_offset) { int ret; robj *kobj = createObject(OBJ_STRING, sdsnewlen(key.data(), key.size())); @@ -60,8 +54,7 @@ RedisCache::BitCount(std::string &key, long start, long end, long *value, bool h return Status::OK(); } -Status -RedisCache::BitPos(std::string &key, long bit, long *value) +Status RedisCache::BitPos(std::string &key, long bit, long *value) { int ret; robj *kobj = createObject(OBJ_STRING, sdsnewlen(key.data(), key.size())); @@ -79,8 +72,7 @@ RedisCache::BitPos(std::string &key, long bit, long *value) return Status::OK(); } -Status -RedisCache::BitPos(std::string &key, long bit, long start, long *value) +Status RedisCache::BitPos(std::string &key, long bit, long start, long *value) { int ret; robj *kobj = createObject(OBJ_STRING, sdsnewlen(key.data(), key.size())); @@ -98,8 +90,7 @@ RedisCache::BitPos(std::string &key, long bit, long start, long *value) return Status::OK(); } -Status -RedisCache::BitPos(std::string &key, long bit, long start, long end, long *value) +Status RedisCache::BitPos(std::string &key, long bit, long start, long end, long *value) { int ret; robj *kobj = createObject(OBJ_STRING, sdsnewlen(key.data(), key.size())); diff --git a/src/dory/src/RedisCache.cc b/src/dory/src/RedisCache.cc index 59632a18d8..281fa5b908 100644 --- a/src/dory/src/RedisCache.cc +++ b/src/dory/src/RedisCache.cc @@ -1,5 +1,7 @@ -#include "RedisCache.h" -#include "pstd_string.h" +#include +#include +#include "dory/include/RedisCache.h" +#include "pstd/include/pstd_string.h" namespace dory { @@ -144,8 +146,7 @@ RedisCache::Del(const std::string &key) return Status::OK(); } -Status -RedisCache::Expire(std::string &key, int64_t ttl) +Status RedisCache::Expire(std::string &key, int64_t ttl) { int ret; robj *kobj = createObject(OBJ_STRING, sdsnewlen(key.data(), key.size())); @@ -164,8 +165,7 @@ RedisCache::Expire(std::string &key, int64_t ttl) return Status::OK(); } -Status -RedisCache::Expireat(std::string &key, int64_t ttl) +Status RedisCache::Expireat(std::string &key, int64_t ttl) { int ret; robj *kobj = createObject(OBJ_STRING, sdsnewlen(key.data(), key.size())); @@ -184,8 +184,7 @@ RedisCache::Expireat(std::string &key, int64_t ttl) return Status::OK(); } -Status -RedisCache::TTL(std::string &key, int64_t *ttl) +Status RedisCache::TTL(std::string &key, int64_t *ttl) { int ret; robj *kobj = createObject(OBJ_STRING, sdsnewlen(key.data(), key.size())); @@ -203,8 +202,7 @@ RedisCache::TTL(std::string &key, int64_t *ttl) return Status::OK(); } -Status -RedisCache::Persist(std::string &key) +Status RedisCache::Persist(std::string &key) { int ret; robj *kobj = createObject(OBJ_STRING, sdsnewlen(key.data(), key.size())); @@ -222,8 +220,7 @@ RedisCache::Persist(std::string &key) return Status::OK(); } -Status -RedisCache::Type(std::string &key, std::string *value) +Status RedisCache::Type(std::string &key, std::string *value) { sds val; int ret; @@ -246,8 +243,7 @@ RedisCache::Type(std::string &key, std::string *value) return Status::OK(); } -Status -RedisCache::RandomKey(std::string *key) +Status RedisCache::RandomKey(std::string *key) { sds val; int ret; @@ -266,16 +262,14 @@ RedisCache::RandomKey(std::string *key) return Status::OK(); } -void -RedisCache::DecrObjectsRefCount(robj *argv1, robj *argv2, robj *argv3) +void RedisCache::DecrObjectsRefCount(robj *argv1, robj *argv2, robj *argv3) { if (NULL != argv1) decrRefCount(argv1); if (NULL != argv2) decrRefCount(argv2); if (NULL != argv3) decrRefCount(argv3); } -void -RedisCache::FreeSdsList(sds *items, unsigned int size) +void RedisCache::FreeSdsList(sds *items, unsigned int size) { unsigned int i; for (i = 0; i < size; ++i) { @@ -284,8 +278,7 @@ RedisCache::FreeSdsList(sds *items, unsigned int size) zfree(items); } -void -RedisCache::FreeObjectList(robj **items, unsigned int size) +void RedisCache::FreeObjectList(robj **items, unsigned int size) { unsigned int i; for (i = 0; i < size; ++i) { @@ -294,8 +287,7 @@ RedisCache::FreeObjectList(robj **items, unsigned int size) zfree(items); } -void -RedisCache::FreeHitemList(hitem *items, unsigned int size) +void RedisCache::FreeHitemList(hitem *items, unsigned int size) { unsigned int i; for (i = 0; i < size; ++i) { @@ -305,8 +297,7 @@ RedisCache::FreeHitemList(hitem *items, unsigned int size) zfree(items); } -void -RedisCache::FreeZitemList(zitem *items, unsigned int size) +void RedisCache::FreeZitemList(zitem *items, unsigned int size) { unsigned int i; for (i = 0; i < size; ++i) { @@ -315,8 +306,7 @@ RedisCache::FreeZitemList(zitem *items, unsigned int size) zfree(items); } -void -RedisCache::ConvertObjectToString(robj *obj, std::string *value) +void RedisCache::ConvertObjectToString(robj *obj, std::string *value) { if (sdsEncodedObject(obj)) { value->assign((char*)obj->ptr, sdslen((sds)obj->ptr)); diff --git a/src/dory/src/RedisHash.cc b/src/dory/src/RedisHash.cc index f5a376ba8d..7c5872cf18 100644 --- a/src/dory/src/RedisHash.cc +++ b/src/dory/src/RedisHash.cc @@ -1,12 +1,11 @@ #include #include +#include "dory/include/RedisCache.h" -#include "RedisCache.h" namespace dory { -Status -RedisCache::HDel(std::string &key, std::vector &fields) +Status RedisCache::HDel(std::string &key, std::vector &fields) { robj *kobj = createObject(OBJ_STRING, sdsnewlen(key.data(), key.size())); robj **fields_obj = (robj **)zcalloc(sizeof(robj*) * fields.size()); @@ -33,8 +32,7 @@ RedisCache::HDel(std::string &key, std::vector &fields) return Status::OK(); } -Status -RedisCache::HSet(std::string &key, std::string &field, std::string &value) +Status RedisCache::HSet(std::string &key, std::string &field, std::string &value) { if (C_OK != RsFreeMemoryIfNeeded(m_RedisDB)) { return Status::Corruption("[error] Free memory faild !"); @@ -52,8 +50,7 @@ RedisCache::HSet(std::string &key, std::string &field, std::string &value) return Status::OK(); } -Status -RedisCache::HSetnx(std::string &key, std::string &field, std::string &value) +Status RedisCache::HSetnx(std::string &key, std::string &field, std::string &value) { if (C_OK != RsFreeMemoryIfNeeded(m_RedisDB)) { return Status::Corruption("[error] Free memory faild !"); @@ -71,8 +68,7 @@ RedisCache::HSetnx(std::string &key, std::string &field, std::string &value) return Status::OK(); } -Status -RedisCache::HMSet(std::string &key, std::vector &fvs) +Status RedisCache::HMSet(std::string &key, std::vector &fvs) { if (C_OK != RsFreeMemoryIfNeeded(m_RedisDB)) { return Status::Corruption("[error] Free memory faild !"); @@ -97,8 +93,7 @@ RedisCache::HMSet(std::string &key, std::vector &fvs) return Status::OK(); } -Status -RedisCache::HGet(std::string &key, std::string &field, std::string *value) +Status RedisCache::HGet(std::string &key, std::string &field, std::string *value) { int ret; sds val; @@ -126,8 +121,7 @@ RedisCache::HGet(std::string &key, std::string &field, std::string *value) return Status::OK(); } -Status -RedisCache::HMGet(std::string &key, +Status RedisCache::HMGet(std::string &key, std::vector &fields, std::vector* vss) { @@ -164,8 +158,7 @@ RedisCache::HMGet(std::string &key, return Status::OK(); } -Status -RedisCache::HGetall(std::string &key, std::vector *fvs) +Status RedisCache::HGetall(std::string &key, std::vector *fvs) { hitem *items; unsigned long items_size; @@ -193,8 +186,7 @@ RedisCache::HGetall(std::string &key, std::vector *fvs) return Status::OK(); } -Status -RedisCache::HKeys(std::string &key, std::vector *fields) +Status RedisCache::HKeys(std::string &key, std::vector *fields) { hitem *items; unsigned long items_size; @@ -219,8 +211,7 @@ RedisCache::HKeys(std::string &key, std::vector *fields) return Status::OK(); } -Status -RedisCache::HVals(std::string &key, std::vector *values) +Status RedisCache::HVals(std::string &key, std::vector *values) { hitem *items; unsigned long items_size; @@ -245,8 +236,7 @@ RedisCache::HVals(std::string &key, std::vector *values) return Status::OK(); } -Status -RedisCache::HExists(std::string &key, std::string &field) +Status RedisCache::HExists(std::string &key, std::string &field) { int ret, is_exist; robj *kobj = createObject(OBJ_STRING, sdsnewlen(key.data(), key.size())); @@ -265,8 +255,7 @@ RedisCache::HExists(std::string &key, std::string &field) return is_exist ? Status::OK() : Status::NotFound("field not exist"); } -Status -RedisCache::HIncrby(std::string &key, std::string &field, int64_t value) +Status RedisCache::HIncrby(std::string &key, std::string &field, int64_t value) { int ret; long long result; @@ -286,8 +275,7 @@ RedisCache::HIncrby(std::string &key, std::string &field, int64_t value) return Status::OK(); } -Status -RedisCache::HIncrbyfloat(std::string &key, std::string &field, long double value) +Status RedisCache::HIncrbyfloat(std::string &key, std::string &field, long double value) { int ret; long double result; @@ -307,8 +295,7 @@ RedisCache::HIncrbyfloat(std::string &key, std::string &field, long double value return Status::OK(); } -Status -RedisCache::HLen(std::string &key, unsigned long *len) +Status RedisCache::HLen(std::string &key, unsigned long *len) { int ret; robj *kobj = createObject(OBJ_STRING, sdsnewlen(key.data(), key.size())); @@ -326,8 +313,7 @@ RedisCache::HLen(std::string &key, unsigned long *len) return Status::OK(); } -Status -RedisCache::HStrlen(std::string &key, std::string &field, unsigned long *len) +Status RedisCache::HStrlen(std::string &key, std::string &field, unsigned long *len) { int ret; robj *kobj = createObject(OBJ_STRING, sdsnewlen(key.data(), key.size())); diff --git a/src/dory/src/RedisList.cc b/src/dory/src/RedisList.cc index 2dfcc8f01d..e767def97b 100644 --- a/src/dory/src/RedisList.cc +++ b/src/dory/src/RedisList.cc @@ -1,9 +1,8 @@ -#include "RedisCache.h" +#include "dory/include/RedisCache.h" namespace dory { -Status -RedisCache::LIndex(std::string &key, long index, std::string *element) +Status RedisCache::LIndex(std::string &key, long index, std::string *element) { sds val; int ret; @@ -29,8 +28,7 @@ RedisCache::LIndex(std::string &key, long index, std::string *element) return Status::OK(); } -Status -RedisCache::LInsert(std::string &key, +Status RedisCache::LInsert(std::string &key, storage::BeforeOrAfter &before_or_after, std::string &pivot, std::string &value) @@ -58,8 +56,7 @@ RedisCache::LInsert(std::string &key, return Status::OK(); } -Status -RedisCache::LLen(std::string &key, unsigned long *len) +Status RedisCache::LLen(std::string &key, unsigned long *len) { int ret; robj *kobj = createObject(OBJ_STRING, sdsnewlen(key.data(), key.size())); @@ -77,8 +74,7 @@ RedisCache::LLen(std::string &key, unsigned long *len) return Status::OK(); } -Status -RedisCache::LPop(std::string &key, std::string *element) +Status RedisCache::LPop(std::string &key, std::string *element) { sds val; int ret; @@ -101,8 +97,7 @@ RedisCache::LPop(std::string &key, std::string *element) return Status::OK(); } -Status -RedisCache::LPush(std::string &key, std::vector &values) +Status RedisCache::LPush(std::string &key, std::vector &values) { if (C_OK != RsFreeMemoryIfNeeded(m_RedisDB)) { return Status::Corruption("[error] Free memory faild !"); @@ -125,8 +120,7 @@ RedisCache::LPush(std::string &key, std::vector &values) return Status::OK(); } -Status -RedisCache::LPushx(std::string &key, std::vector &values) +Status RedisCache::LPushx(std::string &key, std::vector &values) { if (C_OK != RsFreeMemoryIfNeeded(m_RedisDB)) { return Status::Corruption("[error] Free memory faild !"); @@ -156,8 +150,7 @@ RedisCache::LPushx(std::string &key, std::vector &values) return Status::OK(); } -Status -RedisCache::LRange(std::string &key, long start, long stop, std::vector *values) +Status RedisCache::LRange(std::string &key, long start, long stop, std::vector *values) { sds *vals = NULL; unsigned long vals_size; @@ -182,8 +175,7 @@ RedisCache::LRange(std::string &key, long start, long stop, std::vector &values) +Status RedisCache::RPush(std::string &key, std::vector &values) { if (C_OK != RsFreeMemoryIfNeeded(m_RedisDB)) { return Status::Corruption("[error] Free memory faild !"); @@ -292,8 +280,7 @@ RedisCache::RPush(std::string &key, std::vector &values) return Status::OK(); } -Status -RedisCache::RPushx(std::string &key, std::vector &values) +Status RedisCache::RPushx(std::string &key, std::vector &values) { if (C_OK != RsFreeMemoryIfNeeded(m_RedisDB)) { return Status::Corruption("[error] Free memory faild !"); diff --git a/src/dory/src/RedisSet.cc b/src/dory/src/RedisSet.cc index 7a30170c5e..dfa034522c 100644 --- a/src/dory/src/RedisSet.cc +++ b/src/dory/src/RedisSet.cc @@ -1,9 +1,8 @@ -#include "RedisCache.h" +#include "dory/include/RedisCache.h" namespace dory { -Status -RedisCache::SAdd(std::string &key, std::vector &members) +Status RedisCache::SAdd(std::string &key, std::vector &members) { if (C_OK != RsFreeMemoryIfNeeded(m_RedisDB)) { return Status::Corruption("[error] Free memory faild !"); @@ -26,8 +25,7 @@ RedisCache::SAdd(std::string &key, std::vector &members) return Status::OK(); } -Status -RedisCache::SCard(std::string &key, unsigned long *len) +Status RedisCache::SCard(std::string &key, unsigned long *len) { int ret; robj *kobj = createObject(OBJ_STRING, sdsnewlen(key.data(), key.size())); @@ -45,8 +43,7 @@ RedisCache::SCard(std::string &key, unsigned long *len) return Status::OK(); } -Status -RedisCache::SIsmember(std::string &key, std::string &member) +Status RedisCache::SIsmember(std::string &key, std::string &member) { int ret, is_member; robj *kobj = createObject(OBJ_STRING, sdsnewlen(key.data(), key.size())); @@ -65,8 +62,7 @@ RedisCache::SIsmember(std::string &key, std::string &member) return is_member ? Status::OK() : Status::NotFound("member not exist"); } -Status -RedisCache::SMembers(std::string &key, std::vector *members) +Status RedisCache::SMembers(std::string &key, std::vector *members) { sds *vals = NULL; unsigned long vals_size; @@ -91,8 +87,7 @@ RedisCache::SMembers(std::string &key, std::vector *members) return Status::OK(); } -Status -RedisCache::SRem(std::string &key, std::vector &members) +Status RedisCache::SRem(std::string &key, std::vector &members) { robj *kobj = createObject(OBJ_STRING, sdsnewlen(key.data(), key.size())); robj **vals = (robj **)zcalloc(sizeof(robj*) * members.size()); @@ -118,8 +113,7 @@ RedisCache::SRem(std::string &key, std::vector &members) return Status::OK(); } -Status -RedisCache::SRandmember(std::string &key, long count, std::vector *members) +Status RedisCache::SRandmember(std::string &key, long count, std::vector *members) { sds *vals = NULL; unsigned long vals_size = 0; diff --git a/src/dory/src/RedisString.cc b/src/dory/src/RedisString.cc index fd5a73c467..e6931e3a80 100644 --- a/src/dory/src/RedisString.cc +++ b/src/dory/src/RedisString.cc @@ -1,11 +1,10 @@ #include -#include "RedisCache.h" +#include "dory/include/RedisCache.h" namespace dory { -Status -RedisCache::Set(std::string &key, std::string &value, int64_t ttl) +Status RedisCache::Set(std::string &key, std::string &value, int64_t ttl) { if (C_OK != RsFreeMemoryIfNeeded(m_RedisDB)) { return Status::Corruption("[error] Free memory faild !"); @@ -23,8 +22,7 @@ RedisCache::Set(std::string &key, std::string &value, int64_t ttl) DecrObjectsRefCount(kobj, vobj, tobj); return Status::OK(); } -Status -RedisCache::SetWithoutTTL(std::string &key, std::string &value) +Status RedisCache::SetWithoutTTL(std::string &key, std::string &value) { if (C_OK != RsFreeMemoryIfNeeded(m_RedisDB)) { return Status::Corruption("[error] Free memory faild !"); @@ -42,8 +40,7 @@ RedisCache::SetWithoutTTL(std::string &key, std::string &value) return Status::OK(); } -Status -RedisCache::Setnx(std::string &key, std::string &value, int64_t ttl) +Status RedisCache::Setnx(std::string &key, std::string &value, int64_t ttl) { if (C_OK != RsFreeMemoryIfNeeded(m_RedisDB)) { return Status::Corruption("[error] Free memory faild !"); @@ -62,8 +59,7 @@ RedisCache::Setnx(std::string &key, std::string &value, int64_t ttl) return Status::OK(); } -Status -RedisCache::SetnxWithoutTTL(std::string &key, std::string &value) +Status RedisCache::SetnxWithoutTTL(std::string &key, std::string &value) { if (C_OK != RsFreeMemoryIfNeeded(m_RedisDB)) { return Status::Corruption("[error] Free memory faild !"); @@ -81,8 +77,7 @@ RedisCache::SetnxWithoutTTL(std::string &key, std::string &value) return Status::OK(); } -Status -RedisCache::Setxx(std::string &key, std::string &value, int64_t ttl) +Status RedisCache::Setxx(std::string &key, std::string &value, int64_t ttl) { if (C_OK != RsFreeMemoryIfNeeded(m_RedisDB)) { return Status::Corruption("[error] Free memory faild !"); @@ -101,8 +96,7 @@ RedisCache::Setxx(std::string &key, std::string &value, int64_t ttl) return Status::OK(); } -Status -RedisCache::SetxxWithoutTTL(std::string &key, std::string &value) +Status RedisCache::SetxxWithoutTTL(std::string &key, std::string &value) { if (C_OK != RsFreeMemoryIfNeeded(m_RedisDB)) { return Status::Corruption("[error] Free memory faild !"); @@ -119,8 +113,7 @@ RedisCache::SetxxWithoutTTL(std::string &key, std::string &value) DecrObjectsRefCount(kobj, vobj); return Status::OK(); } -Status -RedisCache::Get(const std::string &key, std::string* value) +Status RedisCache::Get(const std::string &key, std::string* value) { robj *val; int ret; @@ -142,8 +135,7 @@ RedisCache::Get(const std::string &key, std::string* value) return Status::OK(); } -Status -RedisCache::Incr(std::string &key) +Status RedisCache::Incr(std::string &key) { long long ret; robj *kobj = createObject(OBJ_STRING, sdsnewlen(key.data(), key.size())); @@ -156,8 +148,7 @@ RedisCache::Incr(std::string &key) return Status::OK(); } -Status -RedisCache::Decr(std::string &key) +Status RedisCache::Decr(std::string &key) { long long ret; robj *kobj = createObject(OBJ_STRING, sdsnewlen(key.data(), key.size())); @@ -170,8 +161,7 @@ RedisCache::Decr(std::string &key) return Status::OK(); } -Status -RedisCache::IncrBy(std::string &key, long long incr) +Status RedisCache::IncrBy(std::string &key, long long incr) { long long ret; robj *kobj = createObject(OBJ_STRING, sdsnewlen(key.data(), key.size())); @@ -184,8 +174,7 @@ RedisCache::IncrBy(std::string &key, long long incr) return Status::OK(); } -Status -RedisCache::DecrBy(std::string &key, long long incr) +Status RedisCache::DecrBy(std::string &key, long long incr) { long long ret; robj *kobj = createObject(OBJ_STRING, sdsnewlen(key.data(), key.size())); @@ -198,8 +187,7 @@ RedisCache::DecrBy(std::string &key, long long incr) return Status::OK(); } -Status -RedisCache::Incrbyfloat(std::string &key, long double incr) +Status RedisCache::Incrbyfloat(std::string &key, long double incr) { long double ret; robj *kobj = createObject(OBJ_STRING, sdsnewlen(key.data(), key.size())); @@ -212,8 +200,7 @@ RedisCache::Incrbyfloat(std::string &key, long double incr) return Status::OK(); } -Status -RedisCache::Append(std::string &key, std::string &value) +Status RedisCache::Append(std::string &key, std::string &value) { unsigned long ret; robj *kobj = createObject(OBJ_STRING, sdsnewlen(key.data(), key.size())); @@ -227,8 +214,7 @@ RedisCache::Append(std::string &key, std::string &value) return Status::OK(); } -Status -RedisCache::GetRange(std::string &key, int64_t start, int64_t end, std::string *value) +Status RedisCache::GetRange(std::string &key, int64_t start, int64_t end, std::string *value) { sds val; int ret; @@ -251,8 +237,7 @@ RedisCache::GetRange(std::string &key, int64_t start, int64_t end, std::string * return Status::OK(); } -Status -RedisCache::SetRange(std::string &key, int64_t start, std::string &value) +Status RedisCache::SetRange(std::string &key, int64_t start, std::string &value) { if (C_OK != RsFreeMemoryIfNeeded(m_RedisDB)) { return Status::Corruption("[error] Free memory faild !"); @@ -270,8 +255,7 @@ RedisCache::SetRange(std::string &key, int64_t start, std::string &value) return Status::OK(); } -Status -RedisCache::Strlen(std::string &key, int32_t *len) +Status RedisCache::Strlen(std::string &key, int32_t *len) { int ret; robj *kobj = createObject(OBJ_STRING, sdsnewlen(key.data(), key.size())); diff --git a/src/dory/src/RedisZset.cc b/src/dory/src/RedisZset.cc index a389f5c333..4b3832a7b0 100644 --- a/src/dory/src/RedisZset.cc +++ b/src/dory/src/RedisZset.cc @@ -1,9 +1,8 @@ -#include "RedisCache.h" +#include "dory/include/RedisCache.h" namespace dory { -Status -RedisCache::ZAdd(std::string &key, std::vector &score_members) +Status RedisCache::ZAdd(std::string &key, std::vector &score_members) { if (C_OK != RsFreeMemoryIfNeeded(m_RedisDB)) { return Status::Corruption("[error] Free memory faild !"); @@ -28,8 +27,7 @@ RedisCache::ZAdd(std::string &key, std::vector &score_memb return Status::OK(); } -Status -RedisCache::ZCard(std::string &key, unsigned long *len) +Status RedisCache::ZCard(std::string &key, unsigned long *len) { int ret; robj *kobj = createObject(OBJ_STRING, sdsnewlen(key.data(), key.size())); @@ -47,8 +45,7 @@ RedisCache::ZCard(std::string &key, unsigned long *len) return Status::OK(); } -Status -RedisCache::ZCount(std::string &key, std::string &min, std::string &max, unsigned long *len) +Status RedisCache::ZCount(std::string &key, std::string &min, std::string &max, unsigned long *len) { int ret; robj *kobj = createObject(OBJ_STRING, sdsnewlen(key.data(), key.size())); @@ -68,8 +65,7 @@ RedisCache::ZCount(std::string &key, std::string &min, std::string &max, unsigne return Status::OK(); } -Status -RedisCache::ZIncrby(std::string &key, std::string &member, double increment) +Status RedisCache::ZIncrby(std::string &key, std::string &member, double increment) { if (C_OK != RsFreeMemoryIfNeeded(m_RedisDB)) { return Status::Corruption("[error] Free memory faild !"); @@ -90,8 +86,7 @@ RedisCache::ZIncrby(std::string &key, std::string &member, double increment) return Status::OK(); } -Status -RedisCache::ZRange(std::string &key, +Status RedisCache::ZRange(std::string &key, long start, long stop, std::vector *score_members) { @@ -121,8 +116,7 @@ RedisCache::ZRange(std::string &key, return Status::OK(); } -Status -RedisCache::ZRangebyscore(std::string &key, +Status RedisCache::ZRangebyscore(std::string &key, std::string &min, std::string &max, std::vector *score_members, int64_t offset, int64_t count) @@ -155,8 +149,7 @@ RedisCache::ZRangebyscore(std::string &key, return Status::OK(); } -Status -RedisCache::ZRank(std::string &key, std::string &member, long *rank) +Status RedisCache::ZRank(std::string &key, std::string &member, long *rank) { int ret; robj *kobj = createObject(OBJ_STRING, sdsnewlen(key.data(), key.size())); @@ -178,8 +171,7 @@ RedisCache::ZRank(std::string &key, std::string &member, long *rank) return Status::OK(); } -Status -RedisCache::ZRem(std::string &key, std::vector &members) +Status RedisCache::ZRem(std::string &key, std::vector &members) { robj *kobj = createObject(OBJ_STRING, sdsnewlen(key.data(), key.size())); robj **members_obj = (robj **)zcalloc(sizeof(robj*) * members.size()); @@ -205,8 +197,7 @@ RedisCache::ZRem(std::string &key, std::vector &members) return Status::OK(); } -Status -RedisCache::ZRemrangebyrank(std::string &key, std::string &min, std::string &max) +Status RedisCache::ZRemrangebyrank(std::string &key, std::string &min, std::string &max) { int ret; robj *kobj = createObject(OBJ_STRING, sdsnewlen(key.data(), key.size())); @@ -226,8 +217,7 @@ RedisCache::ZRemrangebyrank(std::string &key, std::string &min, std::string &max return Status::OK(); } -Status -RedisCache::ZRemrangebyscore(std::string &key, std::string &min, std::string &max) +Status RedisCache::ZRemrangebyscore(std::string &key, std::string &min, std::string &max) { int ret; robj *kobj = createObject(OBJ_STRING, sdsnewlen(key.data(), key.size())); @@ -247,8 +237,7 @@ RedisCache::ZRemrangebyscore(std::string &key, std::string &min, std::string &ma return Status::OK(); } -Status -RedisCache::ZRevrange(std::string &key, +Status RedisCache::ZRevrange(std::string &key, long start, long stop, std::vector *score_members) { @@ -278,8 +267,7 @@ RedisCache::ZRevrange(std::string &key, return Status::OK(); } -Status -RedisCache::ZRevrangebyscore(std::string &key, +Status RedisCache::ZRevrangebyscore(std::string &key, std::string &min, std::string &max, std::vector *score_members, int64_t offset, int64_t count) @@ -312,8 +300,7 @@ RedisCache::ZRevrangebyscore(std::string &key, return Status::OK(); } -Status -RedisCache::ZRevrangebylex(std::string &key, +Status RedisCache::ZRevrangebylex(std::string &key, std::string &min, std::string &max, std::vector *members) { @@ -343,8 +330,7 @@ RedisCache::ZRevrangebylex(std::string &key, return Status::OK(); } -Status -RedisCache::ZRevrank(std::string &key, std::string &member, long *rank) +Status RedisCache::ZRevrank(std::string &key, std::string &member, long *rank) { int ret; robj *kobj = createObject(OBJ_STRING, sdsnewlen(key.data(), key.size())); @@ -366,8 +352,7 @@ RedisCache::ZRevrank(std::string &key, std::string &member, long *rank) return Status::OK(); } -Status -RedisCache::ZScore(std::string &key, std::string &member, double *score) +Status RedisCache::ZScore(std::string &key, std::string &member, double *score) { int ret; robj *kobj = createObject(OBJ_STRING, sdsnewlen(key.data(), key.size())); @@ -389,8 +374,7 @@ RedisCache::ZScore(std::string &key, std::string &member, double *score) return Status::OK(); } -Status -RedisCache::ZRangebylex(std::string &key, +Status RedisCache::ZRangebylex(std::string &key, std::string &min, std::string &max, std::vector *members) { @@ -419,8 +403,7 @@ RedisCache::ZRangebylex(std::string &key, return Status::OK(); } -Status -RedisCache::ZLexcount(std::string &key, std::string &min, std::string &max, unsigned long *len) +Status RedisCache::ZLexcount(std::string &key, std::string &min, std::string &max, unsigned long *len) { int ret; robj *kobj = createObject(OBJ_STRING, sdsnewlen(key.data(), key.size())); @@ -440,8 +423,7 @@ RedisCache::ZLexcount(std::string &key, std::string &min, std::string &max, unsi return Status::OK(); } -Status -RedisCache::ZRemrangebylex(std::string &key, std::string &min, std::string &max) +Status RedisCache::ZRemrangebylex(std::string &key, std::string &min, std::string &max) { int ret; robj *kobj = createObject(OBJ_STRING, sdsnewlen(key.data(), key.size())); diff --git a/src/pika_cache.cc b/src/pika_cache.cc index 8c673b5d12..31837239aa 100644 --- a/src/pika_cache.cc +++ b/src/pika_cache.cc @@ -210,8 +210,6 @@ Status PikaCache::IncrByxx(std::string &key, long long incr) { Status PikaCache::DecrByxx(std::string &key, long long incr) { std::unique_lock l(rwlock_); - - if (cache_->Exists(key)) { return cache_->DecrBy(key, incr); @@ -221,8 +219,6 @@ Status PikaCache::DecrByxx(std::string &key, long long incr) { Status PikaCache::Incrbyfloatxx(std::string &key, long double incr) { std::unique_lock l(rwlock_); - - if (cache_->Exists(key)) { return cache_->Incrbyfloat(key, incr); @@ -240,16 +236,12 @@ Status PikaCache::Appendxx(std::string &key, std::string &value) { Status PikaCache::GetRange(std::string &key, int64_t start, int64_t end, std::string *value) { std::unique_lock l(rwlock_); - - return cache_->GetRange(key, start, end, value); } Status PikaCache::SetRangexx(std::string &key, int64_t start, std::string &value) { std::unique_lock l(rwlock_); - - if (cache_->Exists(key)) { return cache_->SetRange(key, start, value); @@ -259,8 +251,6 @@ Status PikaCache::SetRangexx(std::string &key, int64_t start, std::string &value Status PikaCache::Strlen(std::string &key, int32_t *len) { std::unique_lock l(rwlock_); - - return cache_->Strlen(key, len); } @@ -271,24 +261,18 @@ Status PikaCache::Strlen(std::string &key, int32_t *len) { Status PikaCache::HDel(std::string &key, std::vector &fields) { std::unique_lock l(rwlock_); - - return cache_->HDel(key, fields); } Status PikaCache::HSet(std::string &key, std::string &field, std::string &value) { std::unique_lock l(rwlock_); - - return cache_->HSet(key, field, value); } Status PikaCache::HSetIfKeyExist(std::string &key, std::string &field, std::string &value) { std::unique_lock l(rwlock_); - - if (cache_->Exists(key)) { return cache_->HSet(key, field, value); } @@ -298,8 +282,6 @@ Status PikaCache::HSetIfKeyExist(std::string &key, std::string &field, std::stri Status PikaCache::HSetIfKeyExistAndFieldNotExist(std::string &key, std::string &field, std::string &value) { std::unique_lock l(rwlock_); - - if (cache_->Exists(key)) { return cache_->HSetnx(key, field, value); }