cschaffner / spirit

leaguevine addon to handle WFDF spirit scores
2 stars 0 forks source link

more clever caching #6

Open cschaffner opened 9 years ago

cschaffner commented 9 years ago

keep track which things are stored in the cache. Only flush stuff that is related to an actual edit of a spirit score. That should allow for some long-term caching of stuff that is not changed anymore.

cschaffner commented 9 years ago

After the latest commit 6b00251b9357d67eb32b2255aca8e1840396b0b3 , adding new spirit scores does not automatically clear the whole cache anymore. I realized that spirit scores can only be "added" or "deleted". When adding, we can keep those spirit scores that we already have in the cache and only need to check for any "new ones". This is being done by modifying the "next" field in the "meta" header of a leaguevine API request to the "offset" which equals the current number of objects. In order for this to work, I had to order them decreasingly in the "time_last_modified", and I then reverse them again in spirit_wrapper.py before handing them back.

So, right now, deleting spirit scores is the only action left that completely clears the cache every time it is executed. As I assume "deleting" does not happen frequently, I probably don't bother about this any further.

There are now two different caching times: 5 days for the low-level cache, 1h for the per-view cache of tournaments and seasons.