| 39 | /* ===================== Creation and parsing of objects ==================== */ |
| 40 | |
| 41 | robj *createObject(int type, void *ptr) { |
| 42 | robj *o = zmalloc(sizeof(*o)); |
| 43 | o->type = type; |
| 44 | o->encoding = OBJ_ENCODING_RAW; |
| 45 | o->ptr = ptr; |
| 46 | o->refcount = 1; |
| 47 | |
| 48 | /* Set the LRU to the current lruclock (minutes resolution), or |
| 49 | * alternatively the LFU counter. */ |
| 50 | if (server.maxmemory_policy & MAXMEMORY_FLAG_LFU) { |
| 51 | o->lru = (LFUGetTimeInMinutes()<<8) | LFU_INIT_VAL; |
| 52 | } else { |
| 53 | o->lru = LRU_CLOCK(); |
| 54 | } |
| 55 | return o; |
| 56 | } |
| 57 | |
| 58 | /* Set a special refcount in the object to make it "shared": |
| 59 | * incrRefCount and decrRefCount() will test for this special refcount |
no test coverage detected