Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
brother-jin committed Oct 11, 2023
1 parent 3dc1fb0 commit c47ab5e
Show file tree
Hide file tree
Showing 9 changed files with 96 additions and 200 deletions.
2 changes: 1 addition & 1 deletion src/dory/include/build_version.h
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
23 changes: 7 additions & 16 deletions src/dory/src/RedisBit.cc
Original file line number Diff line number Diff line change
@@ -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 !");
Expand All @@ -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()));
Expand All @@ -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()));
Expand All @@ -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()));
Expand All @@ -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()));
Expand All @@ -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()));
Expand Down
42 changes: 16 additions & 26 deletions src/dory/src/RedisCache.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#include "RedisCache.h"
#include "pstd_string.h"
#include <cstdlib>
#include <cstring>
#include "dory/include/RedisCache.h"
#include "pstd/include/pstd_string.h"

namespace dory {

Expand Down Expand Up @@ -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()));
Expand All @@ -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()));
Expand All @@ -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()));
Expand All @@ -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()));
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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) {
Expand All @@ -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) {
Expand All @@ -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) {
Expand All @@ -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) {
Expand All @@ -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));
Expand Down
44 changes: 15 additions & 29 deletions src/dory/src/RedisHash.cc
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
#include <cstdlib>
#include <cstring>
#include "dory/include/RedisCache.h"

#include "RedisCache.h"

namespace dory {

Status
RedisCache::HDel(std::string &key, std::vector<std::string> &fields)
Status RedisCache::HDel(std::string &key, std::vector<std::string> &fields)
{
robj *kobj = createObject(OBJ_STRING, sdsnewlen(key.data(), key.size()));
robj **fields_obj = (robj **)zcalloc(sizeof(robj*) * fields.size());
Expand All @@ -33,8 +32,7 @@ RedisCache::HDel(std::string &key, std::vector<std::string> &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 !");
Expand All @@ -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 !");
Expand All @@ -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<storage::FieldValue> &fvs)
Status RedisCache::HMSet(std::string &key, std::vector<storage::FieldValue> &fvs)
{
if (C_OK != RsFreeMemoryIfNeeded(m_RedisDB)) {
return Status::Corruption("[error] Free memory faild !");
Expand All @@ -97,8 +93,7 @@ RedisCache::HMSet(std::string &key, std::vector<storage::FieldValue> &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;
Expand Down Expand Up @@ -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<std::string> &fields,
std::vector<storage::ValueStatus>* vss)
{
Expand Down Expand Up @@ -164,8 +158,7 @@ RedisCache::HMGet(std::string &key,
return Status::OK();
}

Status
RedisCache::HGetall(std::string &key, std::vector<storage::FieldValue> *fvs)
Status RedisCache::HGetall(std::string &key, std::vector<storage::FieldValue> *fvs)
{
hitem *items;
unsigned long items_size;
Expand Down Expand Up @@ -193,8 +186,7 @@ RedisCache::HGetall(std::string &key, std::vector<storage::FieldValue> *fvs)
return Status::OK();
}

Status
RedisCache::HKeys(std::string &key, std::vector<std::string> *fields)
Status RedisCache::HKeys(std::string &key, std::vector<std::string> *fields)
{
hitem *items;
unsigned long items_size;
Expand All @@ -219,8 +211,7 @@ RedisCache::HKeys(std::string &key, std::vector<std::string> *fields)
return Status::OK();
}

Status
RedisCache::HVals(std::string &key, std::vector<std::string> *values)
Status RedisCache::HVals(std::string &key, std::vector<std::string> *values)
{
hitem *items;
unsigned long items_size;
Expand All @@ -245,8 +236,7 @@ RedisCache::HVals(std::string &key, std::vector<std::string> *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()));
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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()));
Expand All @@ -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()));
Expand Down
Loading

0 comments on commit c47ab5e

Please sign in to comment.