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
d77e2316
Commit
d77e2316
authored
Mar 20, 2014
by
antirez
Browse files
Specify LRU resolution in milliseconds.
parent
fe308470
Changes
4
Hide whitespace changes
Inline
Side-by-side
src/debug.c
View file @
d77e2316
...
...
@@ -292,7 +292,7 @@ void debugCommand(redisClient *c) {
addReplyStatusFormat
(
c
,
"Value at:%p refcount:%d "
"encoding:%s serializedlength:%lld "
"lru:%d lru_seconds_idle:%lu"
,
"lru:%d lru_seconds_idle:%
l
lu"
,
(
void
*
)
val
,
val
->
refcount
,
strenc
,
(
long
long
)
rdbSavedObjectLen
(
val
),
val
->
lru
,
estimateObjectIdleTime
(
val
));
...
...
src/object.c
View file @
d77e2316
...
...
@@ -650,7 +650,7 @@ char *strEncoding(int encoding) {
/* Given an object returns the min number of seconds the object was never
* requested, using an approximated LRU algorithm. */
unsigned
long
estimateObjectIdleTime
(
robj
*
o
)
{
unsigned
long
long
estimateObjectIdleTime
(
robj
*
o
)
{
if
(
server
.
lruclock
>=
o
->
lru
)
{
return
(
server
.
lruclock
-
o
->
lru
)
*
REDIS_LRU_CLOCK_RESOLUTION
;
}
else
{
...
...
src/redis.c
View file @
d77e2316
...
...
@@ -844,11 +844,10 @@ void activeExpireCycle(int type) {
}
void
updateLRUClock
(
void
)
{
server
.
lruclock
=
(
s
erver
.
unix
time
/
REDIS_LRU_CLOCK_RESOLUTION
)
&
server
.
lruclock
=
(
m
stime
()
/
REDIS_LRU_CLOCK_RESOLUTION
)
&
REDIS_LRU_CLOCK_MAX
;
}
/* Add a sample to the operations per second array of samples. */
void
trackOperationsPerSecond
(
void
)
{
long
long
t
=
mstime
()
-
server
.
ops_sec_last_sample_time
;
...
...
src/redis.h
View file @
d77e2316
...
...
@@ -384,7 +384,7 @@ typedef long long mstime_t; /* millisecond time type. */
/* The actual Redis Object */
#define REDIS_LRU_BITS 22
#define REDIS_LRU_CLOCK_MAX ((1<<REDIS_LRU_BITS)-1)
/* Max value of obj->lru */
#define REDIS_LRU_CLOCK_RESOLUTION 10
/* LRU clock resolution in
second
s */
#define REDIS_LRU_CLOCK_RESOLUTION 10
000
/* LRU clock resolution in
m
s */
typedef
struct
redisObject
{
unsigned
type
:
4
;
unsigned
notused
:
2
;
/* Not used */
...
...
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