Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
ruanhaishen
redis
Commits
8f0b7491
Commit
8f0b7491
authored
Mar 20, 2014
by
antirez
Browse files
Specify LRU resolution in milliseconds.
parent
63aacbe8
Changes
4
Hide whitespace changes
Inline
Side-by-side
src/debug.c
View file @
8f0b7491
...
@@ -292,7 +292,7 @@ void debugCommand(redisClient *c) {
...
@@ -292,7 +292,7 @@ void debugCommand(redisClient *c) {
addReplyStatusFormat
(
c
,
addReplyStatusFormat
(
c
,
"Value at:%p refcount:%d "
"Value at:%p refcount:%d "
"encoding:%s serializedlength:%lld "
"encoding:%s serializedlength:%lld "
"lru:%d lru_seconds_idle:%lu"
,
"lru:%d lru_seconds_idle:%
l
lu"
,
(
void
*
)
val
,
val
->
refcount
,
(
void
*
)
val
,
val
->
refcount
,
strenc
,
(
long
long
)
rdbSavedObjectLen
(
val
),
strenc
,
(
long
long
)
rdbSavedObjectLen
(
val
),
val
->
lru
,
estimateObjectIdleTime
(
val
));
val
->
lru
,
estimateObjectIdleTime
(
val
));
...
...
src/object.c
View file @
8f0b7491
...
@@ -650,7 +650,7 @@ char *strEncoding(int encoding) {
...
@@ -650,7 +650,7 @@ char *strEncoding(int encoding) {
/* Given an object returns the min number of seconds the object was never
/* Given an object returns the min number of seconds the object was never
* requested, using an approximated LRU algorithm. */
* requested, using an approximated LRU algorithm. */
unsigned
long
estimateObjectIdleTime
(
robj
*
o
)
{
unsigned
long
long
estimateObjectIdleTime
(
robj
*
o
)
{
if
(
server
.
lruclock
>=
o
->
lru
)
{
if
(
server
.
lruclock
>=
o
->
lru
)
{
return
(
server
.
lruclock
-
o
->
lru
)
*
REDIS_LRU_CLOCK_RESOLUTION
;
return
(
server
.
lruclock
-
o
->
lru
)
*
REDIS_LRU_CLOCK_RESOLUTION
;
}
else
{
}
else
{
...
...
src/redis.c
View file @
8f0b7491
...
@@ -844,11 +844,10 @@ void activeExpireCycle(int type) {
...
@@ -844,11 +844,10 @@ void activeExpireCycle(int type) {
}
}
void
updateLRUClock
(
void
)
{
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
;
REDIS_LRU_CLOCK_MAX
;
}
}
/* Add a sample to the operations per second array of samples. */
/* Add a sample to the operations per second array of samples. */
void
trackOperationsPerSecond
(
void
)
{
void
trackOperationsPerSecond
(
void
)
{
long
long
t
=
mstime
()
-
server
.
ops_sec_last_sample_time
;
long
long
t
=
mstime
()
-
server
.
ops_sec_last_sample_time
;
...
...
src/redis.h
View file @
8f0b7491
...
@@ -384,7 +384,7 @@ typedef long long mstime_t; /* millisecond time type. */
...
@@ -384,7 +384,7 @@ typedef long long mstime_t; /* millisecond time type. */
/* The actual Redis Object */
/* The actual Redis Object */
#define REDIS_LRU_BITS 22
#define REDIS_LRU_BITS 22
#define REDIS_LRU_CLOCK_MAX ((1<<REDIS_LRU_BITS)-1)
/* Max value of obj->lru */
#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
{
typedef
struct
redisObject
{
unsigned
type
:
4
;
unsigned
type
:
4
;
unsigned
notused
:
2
;
/* Not used */
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