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
dbce190a
Commit
dbce190a
authored
Jul 18, 2016
by
antirez
Browse files
LFU: Fix bugs in frequency decay code.
parent
a8e2d084
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/evict.c
View file @
dbce190a
...
...
@@ -264,7 +264,7 @@ unsigned long LFUGetTimeInMinutes(void) {
* exactly once. */
unsigned
long
LFUTimeElapsed
(
unsigned
long
ldt
)
{
unsigned
long
now
=
LFUGetTimeInMinutes
();
if
(
now
>
ldt
)
return
now
-
ldt
;
if
(
now
>
=
ldt
)
return
now
-
ldt
;
return
65535
-
ldt
+
now
;
}
...
...
@@ -291,7 +291,7 @@ uint8_t LFULogIncr(uint8_t counter) {
unsigned
long
LFUDecrAndReturn
(
robj
*
o
)
{
unsigned
long
ldt
=
o
->
lru
>>
8
;
unsigned
long
counter
=
o
->
lru
&
255
;
if
(
LFUTimeElapsed
(
ldt
)
>
LFU_DECR_INTERVAL
&&
counter
)
{
if
(
LFUTimeElapsed
(
ldt
)
>
=
LFU_DECR_INTERVAL
&&
counter
)
{
if
(
counter
>
LFU_INIT_VAL
*
2
)
{
counter
/=
2
;
if
(
counter
<
LFU_INIT_VAL
*
2
)
counter
=
LFU_INIT_VAL
*
2
;
...
...
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