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 Cache object, which is the main usable object.


>>> s = Scorer(halflife=10)
>>> s.touch('x', cost=2)  # score is similar to cost
>>> s.touch('x')  # scores increase on every touch



touch(key[, cost])

Update score for key Provide a cost the first time and optionally thereafter.