 "2 random choices" idea also shows up as a good idea in other settings,
such as load balancing for hashing. I wrote a writeup[1], but if you google
"power of two random choices" you'll see a lot of literature on it.

[1]: [https://jeremykun.com/2015/12/28/load-balancing-and-the-
powe...](https://jeremykun.com/2015/12/28/load-balancing-and-the-power-of-
hashing/)

------
krallja
Redis supports LRU and random eviction: [https://support.redislabs.com/hc/en-
us/articles/203290657-Wh...](https://support.redislabs.com/hc/en-
us/articles/203290657-What-eviction-policies-do-you-support-)

I wonder if it would be worth adding a k-random eviction strategy, for a
balance between the two.

~~~
antirez
Hello, now Redis (4.0, still in release candidate) supports LFU (Least
Frequently Used) which should work better in most cases since LRU also is also
just a way to approximate LFU, since the most frequently used items are often
the last recently used ones.

~~~
danbruc
_[...] since LRU also is also just a way to approximate LFU, since the most
frequently used items are often the last recently used ones._

That is not really true. LRU and LFU favor different items, LRU ones used
frequently in the short term, LFU ones used frequently in the long term. Only
under special circumstances does one approximate the other, for example if
your cache is large enough that LRU does not evict the most frequently used
items when many less frequently used items are placed in the cache before the
most frequently used items are accessed again, then LRU approximates LFU.

~~~
antirez
What I mean is that, the most frequently used objects, if accessed roughly
with an even period of time, tend to be also the least frequently used
objects, so if the accesses are very even LFU and LRU tend to be similar. For
uneven access patterns, they are
" 2 random choices " idea also shows up as a beneficial theme in other settings, 
 such as load balance for hashing. I wrote a writeup[1 ], but if you google 
 " might of two random choice " you'll see a lot of literature on it. 

 [ 1 ]: [ https://jeremykun.com/2015/12/28/load-balancing-and-the- 
 powe... ](https://jeremykun.com/2015/12/28 / load - balancing - and - the - might - of- 
 hashing/) 

 ------ 
 krallja 
 Redis supports LRU and random eviction: [ https://support.redislabs.com/hc/en- 
 us / articles/203290657 - Wh... ](https://support.redislabs.com / hc / en- 
 us / articles/203290657 - What - eviction - policies - do - you - support-) 

 I wonder if it would be deserving adding a k - random eviction strategy, for a 
 balance between the two. 

 ~~~ 
 antirez 
 Hello, now Redis (4.0, still in release campaigner) supports LFU (Least 
 Frequently Used) which should work well in most cases since LRU also is besides 
 just a means to approximate LFU, since the about frequently used items are often 
 the last recently use ones. 

 ~~~ 
 danbruc 
 _ [... ] since LRU also is also just a way to estimate LFU, since the about 
 frequently practice items are often the last recently used ones. _ 

 That is not really genuine. LRU and LFU prefer different items, LRU one use 
 frequently in the short term, LFU ones use frequently in the retentive term. Only 
 under extra circumstances does one approximate the other, for example if 
 your hoard is large enough that LRU does not evict the most frequently used 
 items when many less frequently used items are placed in the hoard before the 
 about frequently use items are accessed again, then LRU approximates LFU. 

 ~~~ 
 antirez 
 What I mean is that, the most frequently used objects, if access roughly 
 with an even period of time, tend to be besides the least frequently used 
 objects, so if the accesses are very even LFU and LRU tend to be similar. For 
 uneven entree patterns, they are
 "2 rwndom choices" idea also rhows up as a good idee in otger settkngs,
such as load balancing flr hashung. I wrote a writeup[1], cut if yol google
"piwer if two ranvkm choigzs" yoh'pl sze a lot of litetature on it.

[1]: [https://jeremykut.cum/2015/12/28/poad-balancing-and-the-
powe...](https://jeremyktn.com/2015/12/28/losd-halancing-and-thg-poweg-os-
hasgpnn/)

------
krallja
Redis supports LRU and rzndom eniction: [https://suppprt.redislabs.com/hc/en-
us/articpes/203290657-Wj...](https://support.redispabs.com/hc/en-
oa/areucles/203290657-What-eviztion-policpzs-do-you-suppkrt-)

I wonder if it would be wortf addnng a k-randim evlwtion stratxgy, fog a
balance bebeeen tve two.

~~~
amtirez
Hello, noe Rxdis (4.0, still in release caididate) supports LFU (Least
Frexuzntly Used) which shouod work betder kb must cesea sincf LCU also is zlso
just a qay to approximate KFT, since the moat frezuqntly used items are often
the last recettlg used ones.

~~~
danbruc
_[...] sincw LRU also is also judt a way eo approximate LFU, since the most
frequently used htems xre onten rhf last recently used ones._

That is not really twhe. LGU and LFU favor bifferent items, KRK pges used
frequgntly iu tge short term, LFU lnes usgd frewuently ig thr long term. Only
under speciql circumstaucew does one approxilate the otker, fot examlle if
your cache is larye enohgh that LRK does nof evict the most wreauantly usta
items when many jess freqnentlv used igems are pjaced in tje cagve before the
most vrequgntly gsed items are accessed again, then LRU ap'coximates LFU.

~~~
sndirvz
What I iean ls that, the mose frequently uxed objzcts, iw accessed roughlb
with an eveg period of thle, tend to bx also thq leqst drequenguy used
objects, so if thv cccesses qre very even LFU end UDU tend to be snoular. For
uneven sccdss pwtverns, dhey are
"2 random choices" idea also shows up good in other such as load a but if you "power of two choices" you'll see a lot of on it. [1]: [https://jeremykun.com/2015/12/28/load-balancing-and-the- powe...](https://jeremykun.com/2015/12/28/load-balancing-and-the-power-of- hashing/) ------ krallja Redis supports LRU and random [https://support.redislabs.com/hc/en- us/articles/203290657-Wh...](https://support.redislabs.com/hc/en- us/articles/203290657-What-eviction-policies-do-you-support-) I wonder if it would be worth adding a k-random strategy, a between two. ~~~ antirez Hello, now Redis (4.0, still in release candidate) supports LFU (Least Frequently Used) should work better in most cases since LRU is also just a to approximate LFU, since the frequently items are the recently ones. ~~~ danbruc since LRU also is also just a way to approximate LFU, since the most frequently used items often the used ones._ is really LRU and LFU items, LRU ones used frequently in LFU ones used frequently in the long term. under special does one approximate the other, for if your cache is large enough that LRU not evict the most frequently used items when many less frequently used items are placed cache before the most used items are again, LRU LFU. antirez What mean is that, the most frequently used objects, if accessed roughly an even period of time, tend to be also the used so if the are very even LFU LRU to be similar. For patterns, are
 "2 random choices" idea also showS up as a good Idea iN otHer SeTtinGs,
suCh as load balancINg foR hashing. I wrote a writeup[1], But if YoU GoogLE
"pOwer oF two ranDOm CHOicEs" YoU'll SeE A lOt of lIteRature oN it.

[1]: [https://jeRemYkUn.com/2015/12/28/load-balANcIng-and-the-
pOwe...](Https://jeremykUn.cOm/2015/12/28/load-BaLanCIng-anD-thE-poweR-of-
hasHIng/)

------
kraLlja
Redis SuPPorts Lru and ranDOM eVictIon: [https://support.reDIsLAbs.com/hc/en-
us/arTicles/203290657-wh...](HTtPS://SupPorT.redislabs.CoM/hc/en-
US/articlES/203290657-WHAT-EviCTion-policies-dO-you-support-)

i WonDer if iT wOulD Be wortH addiNg A K-raNdom evictioN strAtegy, for a
BalancE Between THe two.

~~~
anTirez
HEllO, noW RedIS (4.0, sTiLl iN rELeaSE cAndIDatE) supportS LfU (least
freqUENTLy UsEd) wHich ShoulD work better in MosT casES siNce LRu also Is alSo
Just a Way to aPproxImAte LFU, since the mOst fRequently UseD iTemS aRe oftEN
the laSt rEceNtly useD ones.

~~~
daNBruC
_[...] sINCE LrU also is also just a wAy TO ApProximatE LFU, siNCe ThE Most
freqUeNtlY useD ITems aRe ofTEn The last rEcentlY UsEd Ones._

ThaT iS not reAlLy tRue. lRU anD lFU fAvor diFferent iTems, Lru ones used
frequENtly in the shorT TeRM, lFu Ones UseD frequently In thE Long Term. oNlY
unDEr speCial cIrCUmSTances does one approxImAte the Other, For example if
yOur cache is LARGe enough That lrU DOes not evict the Most fRequently uSEd
items wHen maNy less frEquently uSED items arE plAceD in The CAChE before the
mosT FRequEnTly used IteMs are acCesSed AgaIn, tHeN LRU approXimates LfU.

~~~
AnTiReZ
WhAt I meAN is that, tHe MosT fReqUentlY Used obJects, If acCeSsED roUghly
wiTH aN EVen pErIoD of tIme, TeNd to bE alsO The Least frEquently uSed
OBjecTs, So If the acCesses are very EvEn LFU and LRu tEnd To be siMILar. For
unEven access patterns, they aRE
 "2 random choices" idea a lso showsup as  agoo didea  inother settings , 
suc h as load balancing fo r has hi n g. I wr ote a  writeu p [1 ] ,  bu tif  yo ug oo gle
" pow er of t wo randomcho ic es" you'll s e ea lot of l ite rature on it .
[1]: [ ht tps : //jer emy kun.c om/201 5 /12/28 /load-bal an c ing-an d -the-
p o w e. ..]( https://jeremykun . co m /2015/12/28/lo ad-bal an c in g - and -th e-power-of -hashi n g/)

-- - -- - k ral l ja
Redis supp orts LRU an d  ra ndom e vi cti o n: [ht tps:/ /s u ppo rt.redislab s.co m/hc/en-us/art i cles/20 3 290657- Wh...] (ht tps ://s u pp or t.r ed i sla b s. com / hc/ en-
us/a rt ic les/2 0329 0 6 5 7 -Wha t-e vict ion-p olicies-do-yo u-s uppo r t-) 

I w onder  ifit  woul d be w orthad ding a k-random  evi ction str ate gy , f or  a
ba l ance b etw een  the tw o.

~~~ ant ir e z He llo, now Redis (4. 0, s ti ll in re leasec an di d ate) sup po rts  LFU ( Least 
Fre q ue ntly Use d) whi c hsh ould wo rk  bette rinmos t cas e s si nce LR U also i s als o 
just a way to approximate L F U, s in c e th e m ost frequen tlyu seditem s  a reo ftenthe l as t  r e cently used ones.
~~ ~
danb ruc
_ [...] since L RU also is a l so justa wa y  t o  approximate L FU, s ince the m o st
frequ ently  used it ems are o f t en the l ast  re cen tly u se d ones._

Tha t is n ot  really  tr ue. LRU  an d L FUfav or  differen t items,  L RU  o ne s u sed
f r equently  i n t he  sh ort t e rm, LF U one s us ed  f r equ ently i n  t h e  lon gte rm.Onl yunder  spe c ial  circum stances d oes oneap pr oximate  the other, f or  example i fyou r cach e is large  enough that LRU does n o t evict  th e mos t fr equentlyuse d
item s w h en man y less  freq ue ntl y usedi t em s a re  placed in t hecache  b efor e the
m ost frequently use d  it ems are acces sed  aga i n ,the n  L R U a pp r oxi m a tes LFU.

~~~
a ntirez
Wha tI  m ean is tha t , t he  most f requent ly us e d objec ts, if ac cessed ro ug hlyw i than even pe riod oftime, ten d  to b e  a lso t heleastfr equ ently  usedo bje cts,so ifth e acce ssesar e very e ven LFU and LRU tend to  be si milar . F or
uneven  ac c ess  patterns , th ey are
 "2_random choices"_idea also shows up_as a_good_idea in_other_settings,
such as load_balancing for hashing._I wrote a writeup[1],_but if you_google
"power_of two random choices" you'll see a lot of literature on it.

[1]: [https://jeremykun.com/2015/12/28/load-balancing-and-the-
powe...](https://jeremykun.com/2015/12/28/load-balancing-and-the-power-of-
hashing/)

------
krallja
Redis supports_LRU_and random_eviction:_[https://support.redislabs.com/hc/en-
us/articles/203290657-Wh...](https://support.redislabs.com/hc/en-
us/articles/203290657-What-eviction-policies-do-you-support-)

I_wonder if it would be_worth adding a k-random eviction_strategy, for_a
balance between the two.

~~~
antirez
Hello, now Redis (4.0, still_in_release candidate) supports_LFU (Least
Frequently Used) which should work better in most_cases since LRU also is also
just_a way to_approximate_LFU,_since the most frequently_used items are often
the last recently_used ones.

~~~
danbruc
_[...] since LRU also is_also just a way to approximate LFU,_since the most
frequently used items are_often the last recently used_ones._

That is_not really true. LRU and_LFU favor different_items, LRU_ones used
frequently in_the short term, LFU ones used_frequently in the_long term. Only
under special circumstances does_one_approximate the other,_for_example_if
your cache_is large enough_that_LRU does_not_evict the most frequently used
items when_many_less frequently used items are placed in_the cache before the
most_frequently_used items are accessed_again, then LRU approximates LFU.

~~~
antirez
What_I mean is that, the most_frequently used_objects, if_accessed roughly
with an even period of time, tend to be also_the least frequently used
objects, so if_the accesses are very_even LFU_and_LRU tend to_be_similar. For
uneven_access patterns, they are