DEV Community 👩‍💻👨‍💻

Discussion on: Implementing a Simple LRU Cache in JavaScript

seanwelshbrown profile image
Sean Welsh Brown Author

Thanks for your feedback Tobias! I was wondering what the best return value would be for when a key wasn't found, you're definitely right about "undefined" or throwing an error being better than returning a string. I'll edit that part to make it a bit more clear.

Also a great suggestion to add a timed-life option, I'll start thinking about how to implement that!

pentacular profile image

Delegate the problem to the caller -- have them provide a value to return in the not-found case.