How to Implement Time-Based Cache in Python: Best Practices and Examples?

20 Replies, 1351 Views

Hey everyone!

So, I’ve been trying to implement time-based cache Python for a project, and I’m kinda stuck on the best way to do it. Like, I know about `@lru_cache` and stuff, but how do you add a time limit to it?

I’ve seen some folks use `datetime` or `time` modules, but idk if that’s the cleanest way. Anyone got tips or examples on how to implement time-based cache Python without overcomplicating things?

Also, what’s the deal with libraries like `cachetools`? Are they worth using, or should I just roll my own solution?

Thanks in advance! 🙌

Messages In This Thread
How to Implement Time-Based Cache in Python: Best Practices and Examples? - by - 14-04-2024, 11:14 PM



Users browsing this thread: 1 Guest(s)