MCPcopy Create free account
hub / github.com/F-Stack/f-stack / createStringObjectFromLongLongWithOptions

Function createStringObjectFromLongLongWithOptions

app/redis-6.2.6/src/object.c:148–172  ·  view source on GitHub ↗

Create a string object from a long long value. When possible returns a * shared integer object, or at least an integer encoded one. * * If valueobj is non zero, the function avoids returning a shared * integer, because the object is going to be used as value in the Redis key * space (for instance when the INCR command is used), so we want LFU/LRU * values specific for each key. */

Source from the content-addressed store, hash-verified

146 * space (for instance when the INCR command is used), so we want LFU/LRU
147 * values specific for each key. */
148robj *createStringObjectFromLongLongWithOptions(long long value, int valueobj) {
149 robj *o;
150
151 if (server.maxmemory == 0 ||
152 !(server.maxmemory_policy & MAXMEMORY_FLAG_NO_SHARED_INTEGERS))
153 {
154 /* If the maxmemory policy permits, we can still return shared integers
155 * even if valueobj is true. */
156 valueobj = 0;
157 }
158
159 if (value >= 0 && value < OBJ_SHARED_INTEGERS && valueobj == 0) {
160 incrRefCount(shared.integers[value]);
161 o = shared.integers[value];
162 } else {
163 if (value >= LONG_MIN && value <= LONG_MAX) {
164 o = createObject(OBJ_STRING, NULL);
165 o->encoding = OBJ_ENCODING_INT;
166 o->ptr = (void*)((long)value);
167 } else {
168 o = createObject(OBJ_STRING,sdsfromlonglong(value));
169 }
170 }
171 return o;
172}
173
174/* Wrapper for createStringObjectFromLongLongWithOptions() always demanding
175 * to create a shared object if possible. */

Calls 3

incrRefCountFunction · 0.85
createObjectFunction · 0.85
sdsfromlonglongFunction · 0.85

Tested by

no test coverage detected