diff --git a/README.md b/README.md index 18c6f19..fc6688d 100644 --- a/README.md +++ b/README.md @@ -27,3 +27,5 @@ Cache with LFU eviction scheme implemented in Python with complexity O(1) for in 1: ['k3'] 2: ['k2'] ``` + +More details: http://www.laurentluce.com/posts/least-frequently-used-cache-eviction-scheme-with-complexity-o1-in-python diff --git a/post.txt b/post.txt index afe9ea5..679abad 100644 --- a/post.txt +++ b/post.txt @@ -135,7 +135,7 @@ class Cache(DoublyLinkedList): Next step is to define methods to insert to the cache, access the cache and delete from the cache. -Let's look at the insert method logic. It takes a key and a value, for example HTTP request and response. If the frequency node with frequency one does not exist, it is inserted at the beginning of the access frequency linked list. An item node is added to the frequency node items linked list. The key and value are added to the dictionary. Complexity is O(1). +Let's look at the insert method logic. It takes a key and value, for example HTTP request and response. If the frequency node with frequency one does not exist, it is inserted at the beginning of the access frequency linked list. An item node is added to the frequency node items linked list. The key and value are added to the dictionary. [code lang="python"] def insert(self, key, value): @@ -153,7 +153,7 @@ We insert two elements in our cache, we end up with: LFU insert method. -Let's look at the access method logic. If the key does not exist, we raise an exception. If the key exists, we move the item node to the frequency node list with frequency + 1 (adding the frequency node if it does not exist). Complexity is O(1). +Let's look at the access method logic. If the key does not exist, we raise an exception. If the key exists, we move the item node to the frequency node list with frequency + 1 (adding the frequency node if it does not exist). [code lang="python"] def access(self, key):