Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit95fc85f

Browse files
authored
Merge pull request#55 from mtzfederico/master
Added info about accessing the cache directly
2 parentsd243517 +1682657 commit95fc85f

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

‎README.md‎

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,29 @@ class MyCustomCache(CacheInterface):
187187
handler= ipinfo.getHandler(cache=MyCustomCache())
188188
```
189189

190+
####Accessing the cache directly
191+
192+
You can access/update the cache directly via a dictionary-like notation with a cache_key and the handler.
193+
194+
```python
195+
>>>import ipinfo
196+
>>>from ipinfo.handler_utilsimport cache_key
197+
>>> access_token='123456789abc'
198+
>>> handler= ipinfo.getHandler(access_token)
199+
>>> ip_cache_key= cache_key('1.1.1.1')
200+
201+
# Check if the ip address is in the cache
202+
>>> ip_cache_keyin handler.cache
203+
True
204+
205+
# Get the ip address's details from cache
206+
>>> handler.cache[ip_cache_key]
207+
{'ip':'1.1.1.1','hostname':'one.one.one.one','anycast':True,'city':'Miami','region':'Florida','country':'US','loc':'25.7867,-80.1800','org':'AS13335 Cloudflare, Inc.','postal':'33132','timezone':'America/New_York','country_name':'United States','latitude':'25.7867','longitude':'-80.1800'}
208+
209+
# Remove the ip address from the cache
210+
>>> handler.cache[ip_cache_key]=None
211+
```
212+
190213
###Modifying request options
191214

192215
**Note**: the asynchronous handler currently only accepts the`timeout` option,

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp