lookupKey函数查看value值
robj *lookupKey(redisDb *db, robj *key) {
dictEntry *de = dictFind(db->dict,key->ptr);
if (de) {
robj *val = dictGetVal(de);
/* Update the access time for the ageing algorithm.
* Don't do it if we have a saving child, as this will trigger
* a copy on write madness. */
if (server.rdb_child_pid == -1 && server.aof_child_pid == -1)
val->lru = server.lruclock;
return val;
} else {
return NULL;
}
}
数据类型,ptr指针指向的就是具体value,需要强制转换
typedef struct redisObject {
unsigned type:4;
unsigned notused:2; /* Not used */
unsigned encoding:4;
unsigned lru:22; /* lru time (relative to server.lruclock) */
int refcount;
void *ptr;
} robj;
(gdb) p (char *)val->ptr
$20 = 0x7ffff7435728 "http://blog.youkuaiyun.com/unix21"
(gdb) p (char *)(*(robj *)(de->v->val))->ptr
$21 = 0x7ffff7435728 "http://blog.youkuaiyun.com/unix21"
(gdb) bt
#0 lookupKey (db=0x7ffff7515300, key=0x7ffff7486330) at db.c:51
#1 0x000000000042bee7 in lookupKeyRead (db=0x7ffff7515300, key=0x7ffff7486330) at db.c:62
#2 0x000000000042bf81 in lookupKeyReadOrReply (c=0x7ffff7531000, key=0x7ffff7486330, reply=0x7ffff7410e50) at db.c:76
#3 0x0000000000433519 in getGenericCommand (c=0x7ffff7531000) at t_string.c:145
#4 0x0000000000433588 in getCommand (c=0x7ffff7531000) at t_string.c:158
#5 0x000000000041ba15 in call (c=0x7ffff7531000, flags=7) at redis.c:1599
#6 0x000000000041c12c in processCommand (c=0x7ffff7531000) at redis.c:1774
#7 0x000000000042874a in processInputBuffer (c=0x7ffff7531000) at networking.c:1013
#8 0x00000000004289f5 in readQueryFromClient (el=0x7ffff7458150, fd=9, privdata=0x7ffff7531000, mask=1) at networking.c:1076
#9 0x0000000000415f5d in aeProcessEvents (eventLoop=0x7ffff7458150, flags=3) at ae.c:382
#10 0x00000000004160f2 in aeMain (eventLoop=0x7ffff7458150) at ae.c:425
#11 0x000000000041e8a7 in main (argc=1, argv=0x7fffffffe578) at redis.c:2721