Skip to content

Commit e06ea40

Browse files
Decrease the default cache period to 10min from 24h
1 parent 22f4b40 commit e06ea40

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

88
## [Unreleased]
9+
### Changed
10+
- Decrease the default cache period to 10min from 24h.
11+
This is to better handle use cases that require fresh [security data](https://ipregistry.co/docs/proxy-tor-threat-detection#content).
12+
Indeed, such data is updated multiple times each hour.
13+
You can still configure the cache period to a higher value:
14+
https://github.com/ipregistry/ipregistry-python#caching
915

1016
## [1.0.0] - 2019-07-28
1117

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,14 +58,14 @@ folder.
5858
### Caching
5959

6060
The Ipregistry client has built-in support for in-memory caching. The default cache strategy is to memoize up to
61-
2048 lookups for at most 24h. You can change preferences as follows:
61+
2048 lookups for at most 10min. You can change preferences as follows:
6262

6363
```python
6464
from ipregistry import DefaultCache, IpregistryClient
6565

66-
client = IpregistryClient("YOUR_API_KEY", cache=DefaultCache(maxsize=4096, ttl=3600))
66+
client = IpregistryClient("YOUR_API_KEY", cache=DefaultCache(maxsize=2048, ttl=600))
6767
```
68-
68+
6969
or disable caching by passing an instance of `NoCache`:
7070

7171
```python

ipregistry/cache.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def invalidateAll(self):
3737
pass
3838

3939
class DefaultCache(IpregistryCache):
40-
def __init__(self, maxsize=2048, ttl=86400):
40+
def __init__(self, maxsize=2048, ttl=600):
4141
self._cache = TTLCache(maxsize, ttl)
4242

4343
def get(self, key):

0 commit comments

Comments
 (0)