Metadata-Version: 2.1
Name: lru-ttl
Version: 0.0.7
Summary: A least recently used (LRU) cache implementation with time to live (TTL)
Home-page: https://github.com/arnov/lru-ttl
Author: Arno Veenstra
Author-email: arnoveenstra@gmail.com
License: UNKNOWN
Platform: UNKNOWN
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 2
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Description-Content-Type: text/markdown

# Introduction

This is a Python LRU cache implementation with TTL support, this way you can ensure you will not get results older than the specified TTL.

# Installation

pip install lru-ttl

# How to use

```python
>>> from lruttl import LRUCache
>>> cache = LRUCache(10)
>>> cache.set('key1', ['some object'], 5)
>>> cache['key1']
['some object']
>>> # wait a couple of seconds
>>> cache['key1']

```

```python
>>> cache = LRUCache(2)
>>> cache.set('key1', 'val1')
>>> cache.set('key2', 'val2')
>>> cache.set('key3', 'val3')
>>> 'key1' in cache
False
>>> 'key2' in cache
True
>>> 'key3' in cache
True
```

The TTL does **not** have precedence, so the last recently used keys will be evicted first!


```python
>>> cache = LRUCache(2)
>>> cache.set('key1', 'val1')
>>> cache.set('key2', 'val2', 10000)
>>> cache.set('key3', 'val3')
>>> 'key1' in cache
False
>>> 'key2' in cache
True
```



