cache Module

Caching.

class wpull.cache.BaseCache[source]

Bases: collections.abc.Mapping, object

clear()[source]

Remove all items in cache.

wpull.cache.Cache

alias of LRUCache

class wpull.cache.CacheItem(key, value, time_to_live=None, access_time=None)[source]

Bases: object

Info about an item in the cache.

Parameters:
  • key – The key
  • value – The value
  • time_to_live – The time in seconds of how long to keep the item
  • access_time – The timestamp of the last use of the item
expire_time

When the item expires.

class wpull.cache.FIFOCache(max_items=None, time_to_live=None)[source]

Bases: wpull.cache.BaseCache

First in first out object cache.

Parameters:
  • max_items (int) – The maximum number of items to keep.
  • time_to_live (float) – Discard items after time_to_live seconds.

Reusing a key to update a value will not affect the expire time of the item.

clear()[source]
trim()[source]

Remove items that are expired or exceed the max size.

class wpull.cache.LRUCache(max_items=None, time_to_live=None)[source]

Bases: wpull.cache.FIFOCache

Least recently used object cache.

Parameters:
  • max_items – The maximum number of items to keep
  • time_to_live – The time in seconds of how long to keep the item
touch(key)[source]
wpull.cache.total_ordering(obj)