| 278 | } |
| 279 | |
| 280 | Status RedisCache::SetRange(std::string& key, int64_t start, std::string &value) { |
| 281 | if (C_OK != RcFreeMemoryIfNeeded(cache_)) { |
| 282 | return Status::Corruption("[error] Free memory faild !"); |
| 283 | } |
| 284 | |
| 285 | uint64_t ret = 0; |
| 286 | robj *kobj = createObject(OBJ_STRING, sdsnewlen(key.data(), key.size())); |
| 287 | robj *vobj = createObject(OBJ_STRING, sdsnewlen(value.data(), value.size())); |
| 288 | DEFER { |
| 289 | DecrObjectsRefCount(kobj, vobj); |
| 290 | }; |
| 291 | int res = RcSetRange(cache_, kobj, start, vobj, reinterpret_cast<unsigned long *>(&ret)); |
| 292 | if (C_OK != res) { |
| 293 | return Status::Corruption("SetRange failed!"); |
| 294 | } |
| 295 | |
| 296 | return Status::OK(); |
| 297 | } |
| 298 | |
| 299 | Status RedisCache::Strlen(std::string& key, int32_t *len) { |
| 300 | robj *kobj = createObject(OBJ_STRING, sdsnewlen(key.data(), key.size())); |
no test coverage detected