trauzti / cache Goto Github PK
View Code? Open in Web Editor NEWA few cache algorithms
A few cache algorithms
a sample data:
4
1
2
2
1
4
1
0
4
4
with cache size=1, then we should get hit count of 3, but current version of OPT gives 2.
Note that when your PUT is actually an overwrite, you shouldn't do eviction (if self.cn == self.c) or +1 (else).
def put(self, key, val=1):
if key not in self.stored:
n = Node(key, val)
self.stored[key] = n
if not self.tail:
self.tail = n
self.update_head(n)
else:
# Overwrite it correctly
n = self.stored[key]
n.val = val
if n != self.head:
self.unlink(n)
self.update_head(n)
if self.cn == self.c:
# Evict the tail
del self.stored[self.tail.key]
self.tail = self.tail.prev
self.tail.next = None
else:
self.cn += 1
Let me know if I misunderstand your code. Thanks!
Hi trauzti,
It seems your result of LIRS is not correct. If you just run the example given by the LIRS paper of Song Jiang, you will find your result is different from that shown in the paper.
W
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.