- class tiled.client.cache.Scorer(halflife)[source]¶
Object to track scores of cache
Prefers items that have the following properties:
1. Expensive to download (bytes) 3. Frequently used 4. Recently used
This object tracks both stated costs of keys and a separate score related to how frequently/recently they have been accessed. It uses these to to provide a score for the key used by the
Cacheobject, which is the main usable object.
>>> s = Scorer(halflife=10) >>> s.touch('x', cost=2) # score is similar to cost 2 >>> s.touch('x') # scores increase on every touch 4.138629436111989
Update score for key Provide a cost the first time and optionally thereafter.