Rust Programming Exercises: LRU Cache

preview_player
Показать описание
In this video we implement an LRU Cache (Least Recently Used) in Rust with a double linked list along side a HashMap. We make use of Smart Pointers (Weak and Reference Counters) to maintain references between nodes and the HashMap. For the LRU cache, we also add the ability to set a capacity and pop least recently used items off of the list.

**Note**:
Because we make use of weak pointers we do not necessarily have to clean up our HashMap when the cache is being used up but it is something should try and implement later by storing the key alongside the node in order to do this. Try updating our implementation to store the key as well and clean up the HashMap whenever the LRU reaches its capacity.

↠ Other Videos to Watch

↠ References:

Cheers! 🍻

🦀 #rust #rustlang #rustprogramming #exercises #programming
Рекомендации по теме
Комментарии
Автор

I am quickly becoming a fan of your videos! I really love how you go into depth on data structures in Rust!

jordanhall
Автор

I think you can encounter an issue with push_node_back if the given node contains some next value, and it would ruin the condition that the tail has null on next. I know that it's not the case for this video, but I just wanted to raise :)

akorchyn