@@ -419,10 +419,7 @@ Status PikaCache::GetRange(std::string& key, int64_t start, int64_t end, std::st
419419Status PikaCache::SetRangexx (std::string& key, int64_t start, std::string &value) {
420420 int cache_index = CacheIndex (key);
421421 std::lock_guard lm (*cache_mutexs_[cache_index]);
422- if (caches_[cache_index]->Exists (key)) {
423- return caches_[cache_index]->SetRange (key, start, value);
424- }
425- return Status::NotFound (" key not exist" );
422+ return caches_[cache_index]->SetRange (key, start, value);
426423}
427424
428425Status PikaCache::Strlen (std::string& key, int32_t *len) {
@@ -443,16 +440,13 @@ Status PikaCache::HDel(std::string& key, std::vector<std::string> &fields) {
443440Status PikaCache::HSet (std::string& key, std::string &field, std::string &value) {
444441 int cache_index = CacheIndex (key);
445442 std::lock_guard lm (*cache_mutexs_[cache_index]);
446- return caches_[cache_index]->HSet (key, field, value);
443+ return caches_[cache_index]->HSetIfKeyExist (key, field, value);
447444}
448445
449446Status PikaCache::HSetIfKeyExist (std::string& key, std::string &field, std::string &value) {
450447 int cache_index = CacheIndex (key);
451448 std::lock_guard lm (*cache_mutexs_[cache_index]);
452- if (caches_[cache_index]->Exists (key)) {
453- return caches_[cache_index]->HSet (key, field, value);
454- }
455- return Status::NotFound (" key not exist" );
449+ return caches_[cache_index]->HSetIfKeyExist (key, field, value);
456450}
457451
458452Status PikaCache::HSetIfKeyExistAndFieldNotExist (std::string& key, std::string &field, std::string &value) {
@@ -496,11 +490,7 @@ Status PikaCache::HMSetnxWithoutTTL(std::string& key, std::vector<storage::Field
496490Status PikaCache::HMSetxx (std::string& key, std::vector<storage::FieldValue> &fvs) {
497491 int cache_index = CacheIndex (key);
498492 std::lock_guard lm (*cache_mutexs_[cache_index]);
499- if (caches_[cache_index]->Exists (key)) {
500- return caches_[cache_index]->HMSet (key, fvs);
501- } else {
502- return Status::NotFound (" key not exist" );
503- }
493+ return caches_[cache_index]->HMSet (key, fvs);
504494}
505495
506496Status PikaCache::HGet (std::string& key, std::string &field, std::string *value) {
@@ -687,10 +677,7 @@ Status PikaCache::SAdd(std::string& key, std::vector<std::string> &members) {
687677Status PikaCache::SAddIfKeyExist (std::string& key, std::vector<std::string> &members) {
688678 int cache_index = CacheIndex (key);
689679 std::lock_guard lm (*cache_mutexs_[cache_index]);
690- if (caches_[cache_index]->Exists (key)) {
691- return caches_[cache_index]->SAdd (key, members);
692- }
693- return Status::NotFound (" key not exist" );
680+ return caches_[cache_index]->SAdd (key, members);
694681}
695682
696683Status PikaCache::SAddnx (std::string& key, std::vector<std::string> &members, int64_t ttl) {
@@ -1566,10 +1553,7 @@ Status PikaCache::SetBit(std::string& key, size_t offset, int64_t value) {
15661553Status PikaCache::SetBitIfKeyExist (std::string& key, size_t offset, int64_t value) {
15671554 int cache_index = CacheIndex (key);
15681555 std::lock_guard lm (*cache_mutexs_[cache_index]);
1569- if (caches_[cache_index]->Exists (key)) {
1570- return caches_[cache_index]->SetBit (key, offset, value);
1571- }
1572- return Status::NotFound (" key not exist" );
1556+ return caches_[cache_index]->SetBit (key, offset, value);
15731557}
15741558
15751559Status PikaCache::GetBit (std::string& key, size_t offset, int64_t *value) {
0 commit comments