MCPcopy Create free account
hub / github.com/Snapchat/KeyDB / RM_ModuleTypeSetValue

Function RM_ModuleTypeSetValue

src/module.cpp:4664–4672  ·  view source on GitHub ↗

If the key is open for writing, set the specified module type object * as the value of the key, deleting the old value if any. * On success REDISMODULE_OK is returned. If the key is not open for * writing or there is an active iterator, REDISMODULE_ERR is returned. */

Source from the content-addressed store, hash-verified

4662 * On success REDISMODULE_OK is returned. If the key is not open for
4663 * writing or there is an active iterator, REDISMODULE_ERR is returned. */
4664int RM_ModuleTypeSetValue(RedisModuleKey *key, moduleType *mt, void *value) {
4665 if (!(key->mode & REDISMODULE_WRITE) || key->iter) return REDISMODULE_ERR;
4666 RM_DeleteKey(key);
4667 robj *o = createModuleObject(mt,value);
4668 genericSetKey(key->ctx->client,key->db,key->key,o,0,0);
4669 decrRefCount(o);
4670 key->value = o;
4671 return REDISMODULE_OK;
4672}
4673
4674/* Assuming RedisModule_KeyType() returned REDISMODULE_KEYTYPE_MODULE on
4675 * the key, returns the module type pointer of the value stored at key.

Callers

nothing calls this directly

Calls 4

RM_DeleteKeyFunction · 0.85
createModuleObjectFunction · 0.85
genericSetKeyFunction · 0.85
decrRefCountFunction · 0.85

Tested by

no test coverage detected