将缓存添加到lambda代理
lambda-proxy-cache的Python项目详细描述
lambda代理缓存
将缓存层添加到lambda-proxy
安装
$ pip install -U pip $ pip install lambda-proxy-cache
或从源安装:
$ git clone https://github.com/vincentsarago/lambda-proxy-cache.git
$ cd lambda-proxy-cache
$ pip install -U pip
$ pip install -e .
用法
fromlambda_proxy_cache.proxyimportAPIfromlambda_proxy_cache.backends.memcacheimportMemcachedCacheapp=API(name="app",cache_layer=MemcachedCache("MyHostURL"))@app.route('/user/<name>')defprint_name(name):# Do something here...return('OK','plain/text',name)# By adding `no_cache=True` we tell the proxy to not use the cache@app.route('/user/<name>/id',no_cache=True)defprint_id(name):# Do something here...return('OK','plain/text',id)
贡献与发展
问题和拉取请求非常受欢迎。
dev安装和拉取请求
$ git clone https://github.com/vincentsarago/lambda-proxy-cache.git $ cd lambda-proxy-cache $ pip install -e .[dev]
此repo设置为在提交新代码时使用pre-commit运行flake8、pydocstring和black(“不妥协的python代码格式化程序”)。
$ pre-commit install
$ git add .
$ git commit -m'my change'
black.........................Passed
Flake8........................Passed
Verifying PEP257 Compliance...Passed
$ git push origin