In one of my recent projects, there was a requirement to cache data for a stipulated period of time (say 3 minutes) in order to prevent frequent database look-ups. Obviously, improving the efficiency of the system was also another requirement. 😉
Via illustrations as shown below, I have made a basic flowchart about the different steps/events which might be encountered while developing a low-cost, inexpensive, custom, in-memory & timestamp-based cache mechanism. Various different Data structures can also be utilized as per the requirement.
The second conditional expression can be as follows:
if(((new Date()).time – timeStampObj[Identifier]) < 180001) //ACTIONSCRIPT
……………… and so on
This is because
1) ‘time’ property of Date class returns back the current time in milliseconds (since 1st Jan, 1970)
2) timeStampObj Dictionary stores data as <Identifier, time in milliseconds>
3) Since the stipulated time-period is 3 min (180,000 milliseconds), it is logical to check “less than 180001” condition
Login