Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
redis
Commits
ece74202
Commit
ece74202
authored
Apr 06, 2011
by
antirez
Browse files
OBJECT command implemented
parent
f797c7dc
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/object.c
View file @
ece74202
...
@@ -416,3 +416,42 @@ unsigned long estimateObjectIdleTime(robj *o) {
...
@@ -416,3 +416,42 @@ unsigned long estimateObjectIdleTime(robj *o) {
REDIS_LRU_CLOCK_RESOLUTION
;
REDIS_LRU_CLOCK_RESOLUTION
;
}
}
}
}
/* This is an helper function for the DEBUG command. We need to lookup keys
* without any modification of LRU or other parameters. */
robj
*
objectCommandLookup
(
redisClient
*
c
,
robj
*
key
)
{
dictEntry
*
de
;
if
((
de
=
dictFind
(
c
->
db
->
dict
,
key
->
ptr
))
==
NULL
)
return
NULL
;
return
(
robj
*
)
dictGetEntryVal
(
de
);
}
robj
*
objectCommandLookupOrReply
(
redisClient
*
c
,
robj
*
key
,
robj
*
reply
)
{
robj
*
o
=
objectCommandLookup
(
c
,
key
);
if
(
!
o
)
addReply
(
c
,
reply
);
return
o
;
}
/* Object command allows to inspect the internals of an Redis Object.
* Usage: OBJECT <verb> ... arguments ... */
void
objectCommand
(
redisClient
*
c
)
{
robj
*
o
;
if
(
!
strcasecmp
(
c
->
argv
[
1
]
->
ptr
,
"refcount"
)
&&
c
->
argc
==
3
)
{
if
((
o
=
objectCommandLookupOrReply
(
c
,
c
->
argv
[
2
],
shared
.
nullbulk
))
==
NULL
)
return
;
addReplyLongLong
(
c
,
o
->
refcount
);
}
else
if
(
!
strcasecmp
(
c
->
argv
[
1
]
->
ptr
,
"encoding"
)
&&
c
->
argc
==
3
)
{
if
((
o
=
objectCommandLookupOrReply
(
c
,
c
->
argv
[
2
],
shared
.
nullbulk
))
==
NULL
)
return
;
addReplyBulkCString
(
c
,
strEncoding
(
o
->
encoding
));
}
else
if
(
!
strcasecmp
(
c
->
argv
[
1
]
->
ptr
,
"idletime"
)
&&
c
->
argc
==
3
)
{
if
((
o
=
objectCommandLookupOrReply
(
c
,
c
->
argv
[
2
],
shared
.
nullbulk
))
==
NULL
)
return
;
addReplyLongLong
(
c
,
estimateObjectIdleTime
(
o
));
}
else
{
addReplyError
(
c
,
"Syntax error. Try OBJECT (refcount|encoding|idletime)"
);
}
}
src/redis.c
View file @
ece74202
...
@@ -191,7 +191,8 @@ struct redisCommand redisCommandTable[] = {
...
@@ -191,7 +191,8 @@ struct redisCommand redisCommandTable[] = {
{
"cluster"
,
clusterCommand
,
-
2
,
0
,
NULL
,
0
,
0
,
0
,
0
,
0
},
{
"cluster"
,
clusterCommand
,
-
2
,
0
,
NULL
,
0
,
0
,
0
,
0
,
0
},
{
"restore"
,
restoreCommand
,
4
,
0
,
NULL
,
0
,
0
,
0
,
0
,
0
},
{
"restore"
,
restoreCommand
,
4
,
0
,
NULL
,
0
,
0
,
0
,
0
,
0
},
{
"migrate"
,
migrateCommand
,
6
,
0
,
NULL
,
0
,
0
,
0
,
0
,
0
},
{
"migrate"
,
migrateCommand
,
6
,
0
,
NULL
,
0
,
0
,
0
,
0
,
0
},
{
"dump"
,
dumpCommand
,
2
,
0
,
NULL
,
0
,
0
,
0
,
0
,
0
}
{
"dump"
,
dumpCommand
,
2
,
0
,
NULL
,
0
,
0
,
0
,
0
,
0
},
{
"object"
,
objectCommand
,
-
2
,
0
,
NULL
,
0
,
0
,
0
,
0
,
0
}
};
};
/*============================ Utility functions ============================ */
/*============================ Utility functions ============================ */
...
...
src/redis.h
View file @
ece74202
...
@@ -1181,6 +1181,7 @@ void clusterCommand(redisClient *c);
...
@@ -1181,6 +1181,7 @@ void clusterCommand(redisClient *c);
void
restoreCommand
(
redisClient
*
c
);
void
restoreCommand
(
redisClient
*
c
);
void
migrateCommand
(
redisClient
*
c
);
void
migrateCommand
(
redisClient
*
c
);
void
dumpCommand
(
redisClient
*
c
);
void
dumpCommand
(
redisClient
*
c
);
void
objectCommand
(
redisClient
*
c
);
#if defined(__GNUC__)
#if defined(__GNUC__)
void
*
calloc
(
size_t
count
,
size_t
size
)
__attribute__
((
deprecated
));
void
*
calloc
(
size_t
count
,
size_t
size
)
__attribute__
((
deprecated
));
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment