python 3.x - find a data type suitable for my cache -
I want to cache my object in the display, but it needs to be recycle if it is not too long is.
The function will be called every 30 minutes, check each cache object, such as the file's attributes in the Windows Operations system, each object should have two attributes: the last modified time stamp (or a flag) ) And the last accessed time stamp, if the last modified time is greater than zero, then make a SQL to update them in the database and reset the modified time to 0 , If the last access time is more than 30 minutes, remove them from the cache system.
What is the best way to implement them? And there is a similar system already in Python so I do not need to change the wheel again.
ps should not have any memkached objects directly, no serialization and no discretion.
You can either create a class with these attributes, or you just use one dictionary Do it is a matter of taste, both works, being a class gives you the possibility of making methods like "is_old" or "is_modified" etc.
The same structure goes to capture all the data, it is basically a huge dictionary, but you want to wrap it in a class with methods like "purge_old" and so on.
Comments
Post a Comment