Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/globocom/tornado-stale-client
An async http client for tornado with stale cache support
https://github.com/globocom/tornado-stale-client
Last synced: about 2 months ago
JSON representation
An async http client for tornado with stale cache support
- Host: GitHub
- URL: https://github.com/globocom/tornado-stale-client
- Owner: globocom
- License: mit
- Created: 2016-02-18T18:34:45.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2017-10-05T15:16:08.000Z (over 7 years ago)
- Last Synced: 2024-11-16T01:37:54.096Z (about 2 months ago)
- Language: Python
- Size: 22.5 KB
- Stars: 7
- Watchers: 15
- Forks: 4
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- starred-awesome - tornado-stale-client - An async http client for tornado with stale cache support (Python)
README
# tornado-stale-client
[![Build Status](https://travis-ci.org/globocom/tornado-stale-client.svg?branch=master)](https://travis-ci.org/globocom/tornado-stale-client)
An async http client for tornado with stale cache support.
# Using
```python
from smart_sentinel.tornado_client import TornadoStrictRedis
from tornado_stale_client import StaleHTTPClient@gen.coroutine
def main():
cache = TornadoStrictRedis()
client = StaleHTTPClient(cache=cache)response = yield client.fetch('http://...')
print(response.code, 'GET', url, response.body)
```You can also configure `ttl` and `stale_ttl` per request
```python
# ...
response = yield client.fetch('http://...', ttl=1, stale_ttl=300)
```Check [example.py](example.py) for a runnable demo.
# Options
The client accepts the following options:
| Option | Description | Default |
|--------------------|--------------------------------------------------------------------|----------------------------------------------------|
| cache | Async `TornadoStrictRedis` instance or compatible | `smart_sentinel.tornado_client.TornadoStrictRedis` |
| client | Accepts any compatible tornado async http client | `tornado.httpclient.AsyncHTTPClient` |
| primary_key_prefix | Prefix to use for the primary cache | "primary_http" |
| stale_key_prefix | Prefix to use for the stale cache | "stale_http" |
| ttl | `float`, time in seconds to keep the response in the primary cache | 5.0 |
| vary | list of headers in which the cache should vary | None |# Installing
```
pip install tornado-stale-client
```# Testing / contributing
Clone, setup, test.
```
make setup
make test
```# Releasing
* Bump to a `patch`, `minor` or `major` version.
```
# By default bumps to a patch version
make bump# Or specific bump
make patch bump
make minor bump
make major bump
```* Upload release to PyPI
The name of the server on `.pypirc` will be asked.
```
make release
```