summaryrefslogtreecommitdiff
path: root/python-aiohttp-cache.spec
diff options
context:
space:
mode:
Diffstat (limited to 'python-aiohttp-cache.spec')
-rw-r--r--python-aiohttp-cache.spec642
1 files changed, 642 insertions, 0 deletions
diff --git a/python-aiohttp-cache.spec b/python-aiohttp-cache.spec
new file mode 100644
index 0000000..6ddb153
--- /dev/null
+++ b/python-aiohttp-cache.spec
@@ -0,0 +1,642 @@
+%global _empty_manifest_terminate_build 0
+Name: python-aiohttp-cache
+Version: 4.0.1
+Release: 1
+Summary: A cache system for aiohttp server
+License: BSD
+URL: https://github.com/cr0hn/aiohttp-cache
+Source0: https://mirrors.nju.edu.cn/pypi/web/packages/47/ef/9e84ebb7236e833218d20a83cc598af2844ffb2aeb8b38fe88e7b64b78d4/aiohttp_cache-4.0.1.tar.gz
+BuildArch: noarch
+
+Requires: python3-aiohttp
+Requires: python3-envparse
+Requires: python3-redis
+
+%description
+# Aiohttp-cache
+
+![aiohttp-cache logo](https://raw.githubusercontent.com/cr0hn/aiohttp-cache/master/aiohttp-cache-128x128.png)
+
+
+# What's aiohttp-cache
+
+`aiohttp-cache` is a plugin for aiohttp.web server that allow to use a
+cache system to improve the performance of your site.
+
+# How to use it
+
+## With in-memory backend
+
+```python
+import asyncio
+
+from aiohttp import web
+
+from aiohttp_cache import ( # noqa
+ setup_cache,
+ cache,
+)
+
+PAYLOAD = {"hello": "aiohttp_cache"}
+WAIT_TIME = 2
+
+
+@cache()
+async def some_long_running_view(
+ request: web.Request,
+) -> web.Response:
+ await asyncio.sleep(WAIT_TIME)
+ payload = await request.json()
+ return web.json_response(payload)
+
+
+app = web.Application()
+setup_cache(app)
+app.router.add_post("/", some_long_running_view)
+
+web.run_app(app)
+```
+
+## With redis backend
+
+**Note**: redis should be available at
+ `$CACHE_URL` env variable or`redis://localhost:6379/0`
+
+```python
+import asyncio
+
+import yarl
+from aiohttp import web
+from envparse import env
+
+from aiohttp_cache import ( # noqa
+ setup_cache,
+ cache,
+ RedisConfig,
+)
+
+PAYLOAD = {"hello": "aiohttp_cache"}
+WAIT_TIME = 2
+
+
+@cache()
+async def some_long_running_view(
+ request: web.Request,
+) -> web.Response:
+ await asyncio.sleep(WAIT_TIME)
+ payload = await request.json()
+ return web.json_response(payload)
+
+
+app = web.Application()
+url = yarl.URL(
+ env.str("CACHE_URL", default="redis://localhost:6379/0")
+)
+setup_cache(
+ app,
+ cache_type="redis",
+ backend_config=RedisConfig(
+ db=int(url.path[1:]), host=url.host, port=url.port
+ ),
+)
+
+app.router.add_post("/", some_long_running_view)
+
+web.run_app(app)
+```
+
+## Example with a custom cache key
+
+Let's say you would like to cache the requests just by the method and
+json payload, then you can setup this as per the follwing example.
+
+**Note** default key_pattern is:
+
+```python
+DEFAULT_KEY_PATTERN = (
+ AvailableKeys.method,
+ AvailableKeys.host,
+ AvailableKeys.path,
+ AvailableKeys.postdata,
+ AvailableKeys.ctype,
+)
+```
+
+```python
+import asyncio
+
+from aiohttp import web
+
+from aiohttp_cache import (
+ setup_cache,
+ cache,
+ AvailableKeys,
+) # noqa
+
+PAYLOAD = {"hello": "aiohttp_cache"}
+WAIT_TIME = 2
+
+
+@cache()
+async def some_long_running_view(
+ request: web.Request,
+) -> web.Response:
+ await asyncio.sleep(WAIT_TIME)
+ payload = await request.json()
+ return web.json_response(payload)
+
+
+custom_cache_key = (AvailableKeys.method, AvailableKeys.json)
+
+app = web.Application()
+setup_cache(app, key_pattern=custom_cache_key)
+app.router.add_post("/", some_long_running_view)
+
+web.run_app(app)
+```
+
+## Parametrize the cache decorator
+
+```python
+import asyncio
+
+from aiohttp import web
+
+from aiohttp_cache import ( # noqa
+ setup_cache,
+ cache,
+)
+
+PAYLOAD = {"hello": "aiohttp_cache"}
+WAIT_TIME = 2
+
+
+@cache(
+ expires=1 * 24 * 3600, # in seconds
+ unless=False, # anything what returns a bool. if True - skips cache
+)
+async def some_long_running_view(
+ request: web.Request,
+) -> web.Response:
+ await asyncio.sleep(WAIT_TIME)
+ payload = await request.json()
+ return web.json_response(payload)
+
+
+app = web.Application()
+setup_cache(app)
+app.router.add_post("/", some_long_running_view)
+
+web.run_app(app)
+```
+
+# License
+
+This project is released under BSD license. Feel free
+
+# Source Code
+
+The latest developer version is available in a github repository:
+<https://github.com/cr0hn/aiohttp-cache>
+
+# Development environment
+
+1. docker-compose run tests
+
+
+%package -n python3-aiohttp-cache
+Summary: A cache system for aiohttp server
+Provides: python-aiohttp-cache
+BuildRequires: python3-devel
+BuildRequires: python3-setuptools
+BuildRequires: python3-pip
+%description -n python3-aiohttp-cache
+# Aiohttp-cache
+
+![aiohttp-cache logo](https://raw.githubusercontent.com/cr0hn/aiohttp-cache/master/aiohttp-cache-128x128.png)
+
+
+# What's aiohttp-cache
+
+`aiohttp-cache` is a plugin for aiohttp.web server that allow to use a
+cache system to improve the performance of your site.
+
+# How to use it
+
+## With in-memory backend
+
+```python
+import asyncio
+
+from aiohttp import web
+
+from aiohttp_cache import ( # noqa
+ setup_cache,
+ cache,
+)
+
+PAYLOAD = {"hello": "aiohttp_cache"}
+WAIT_TIME = 2
+
+
+@cache()
+async def some_long_running_view(
+ request: web.Request,
+) -> web.Response:
+ await asyncio.sleep(WAIT_TIME)
+ payload = await request.json()
+ return web.json_response(payload)
+
+
+app = web.Application()
+setup_cache(app)
+app.router.add_post("/", some_long_running_view)
+
+web.run_app(app)
+```
+
+## With redis backend
+
+**Note**: redis should be available at
+ `$CACHE_URL` env variable or`redis://localhost:6379/0`
+
+```python
+import asyncio
+
+import yarl
+from aiohttp import web
+from envparse import env
+
+from aiohttp_cache import ( # noqa
+ setup_cache,
+ cache,
+ RedisConfig,
+)
+
+PAYLOAD = {"hello": "aiohttp_cache"}
+WAIT_TIME = 2
+
+
+@cache()
+async def some_long_running_view(
+ request: web.Request,
+) -> web.Response:
+ await asyncio.sleep(WAIT_TIME)
+ payload = await request.json()
+ return web.json_response(payload)
+
+
+app = web.Application()
+url = yarl.URL(
+ env.str("CACHE_URL", default="redis://localhost:6379/0")
+)
+setup_cache(
+ app,
+ cache_type="redis",
+ backend_config=RedisConfig(
+ db=int(url.path[1:]), host=url.host, port=url.port
+ ),
+)
+
+app.router.add_post("/", some_long_running_view)
+
+web.run_app(app)
+```
+
+## Example with a custom cache key
+
+Let's say you would like to cache the requests just by the method and
+json payload, then you can setup this as per the follwing example.
+
+**Note** default key_pattern is:
+
+```python
+DEFAULT_KEY_PATTERN = (
+ AvailableKeys.method,
+ AvailableKeys.host,
+ AvailableKeys.path,
+ AvailableKeys.postdata,
+ AvailableKeys.ctype,
+)
+```
+
+```python
+import asyncio
+
+from aiohttp import web
+
+from aiohttp_cache import (
+ setup_cache,
+ cache,
+ AvailableKeys,
+) # noqa
+
+PAYLOAD = {"hello": "aiohttp_cache"}
+WAIT_TIME = 2
+
+
+@cache()
+async def some_long_running_view(
+ request: web.Request,
+) -> web.Response:
+ await asyncio.sleep(WAIT_TIME)
+ payload = await request.json()
+ return web.json_response(payload)
+
+
+custom_cache_key = (AvailableKeys.method, AvailableKeys.json)
+
+app = web.Application()
+setup_cache(app, key_pattern=custom_cache_key)
+app.router.add_post("/", some_long_running_view)
+
+web.run_app(app)
+```
+
+## Parametrize the cache decorator
+
+```python
+import asyncio
+
+from aiohttp import web
+
+from aiohttp_cache import ( # noqa
+ setup_cache,
+ cache,
+)
+
+PAYLOAD = {"hello": "aiohttp_cache"}
+WAIT_TIME = 2
+
+
+@cache(
+ expires=1 * 24 * 3600, # in seconds
+ unless=False, # anything what returns a bool. if True - skips cache
+)
+async def some_long_running_view(
+ request: web.Request,
+) -> web.Response:
+ await asyncio.sleep(WAIT_TIME)
+ payload = await request.json()
+ return web.json_response(payload)
+
+
+app = web.Application()
+setup_cache(app)
+app.router.add_post("/", some_long_running_view)
+
+web.run_app(app)
+```
+
+# License
+
+This project is released under BSD license. Feel free
+
+# Source Code
+
+The latest developer version is available in a github repository:
+<https://github.com/cr0hn/aiohttp-cache>
+
+# Development environment
+
+1. docker-compose run tests
+
+
+%package help
+Summary: Development documents and examples for aiohttp-cache
+Provides: python3-aiohttp-cache-doc
+%description help
+# Aiohttp-cache
+
+![aiohttp-cache logo](https://raw.githubusercontent.com/cr0hn/aiohttp-cache/master/aiohttp-cache-128x128.png)
+
+
+# What's aiohttp-cache
+
+`aiohttp-cache` is a plugin for aiohttp.web server that allow to use a
+cache system to improve the performance of your site.
+
+# How to use it
+
+## With in-memory backend
+
+```python
+import asyncio
+
+from aiohttp import web
+
+from aiohttp_cache import ( # noqa
+ setup_cache,
+ cache,
+)
+
+PAYLOAD = {"hello": "aiohttp_cache"}
+WAIT_TIME = 2
+
+
+@cache()
+async def some_long_running_view(
+ request: web.Request,
+) -> web.Response:
+ await asyncio.sleep(WAIT_TIME)
+ payload = await request.json()
+ return web.json_response(payload)
+
+
+app = web.Application()
+setup_cache(app)
+app.router.add_post("/", some_long_running_view)
+
+web.run_app(app)
+```
+
+## With redis backend
+
+**Note**: redis should be available at
+ `$CACHE_URL` env variable or`redis://localhost:6379/0`
+
+```python
+import asyncio
+
+import yarl
+from aiohttp import web
+from envparse import env
+
+from aiohttp_cache import ( # noqa
+ setup_cache,
+ cache,
+ RedisConfig,
+)
+
+PAYLOAD = {"hello": "aiohttp_cache"}
+WAIT_TIME = 2
+
+
+@cache()
+async def some_long_running_view(
+ request: web.Request,
+) -> web.Response:
+ await asyncio.sleep(WAIT_TIME)
+ payload = await request.json()
+ return web.json_response(payload)
+
+
+app = web.Application()
+url = yarl.URL(
+ env.str("CACHE_URL", default="redis://localhost:6379/0")
+)
+setup_cache(
+ app,
+ cache_type="redis",
+ backend_config=RedisConfig(
+ db=int(url.path[1:]), host=url.host, port=url.port
+ ),
+)
+
+app.router.add_post("/", some_long_running_view)
+
+web.run_app(app)
+```
+
+## Example with a custom cache key
+
+Let's say you would like to cache the requests just by the method and
+json payload, then you can setup this as per the follwing example.
+
+**Note** default key_pattern is:
+
+```python
+DEFAULT_KEY_PATTERN = (
+ AvailableKeys.method,
+ AvailableKeys.host,
+ AvailableKeys.path,
+ AvailableKeys.postdata,
+ AvailableKeys.ctype,
+)
+```
+
+```python
+import asyncio
+
+from aiohttp import web
+
+from aiohttp_cache import (
+ setup_cache,
+ cache,
+ AvailableKeys,
+) # noqa
+
+PAYLOAD = {"hello": "aiohttp_cache"}
+WAIT_TIME = 2
+
+
+@cache()
+async def some_long_running_view(
+ request: web.Request,
+) -> web.Response:
+ await asyncio.sleep(WAIT_TIME)
+ payload = await request.json()
+ return web.json_response(payload)
+
+
+custom_cache_key = (AvailableKeys.method, AvailableKeys.json)
+
+app = web.Application()
+setup_cache(app, key_pattern=custom_cache_key)
+app.router.add_post("/", some_long_running_view)
+
+web.run_app(app)
+```
+
+## Parametrize the cache decorator
+
+```python
+import asyncio
+
+from aiohttp import web
+
+from aiohttp_cache import ( # noqa
+ setup_cache,
+ cache,
+)
+
+PAYLOAD = {"hello": "aiohttp_cache"}
+WAIT_TIME = 2
+
+
+@cache(
+ expires=1 * 24 * 3600, # in seconds
+ unless=False, # anything what returns a bool. if True - skips cache
+)
+async def some_long_running_view(
+ request: web.Request,
+) -> web.Response:
+ await asyncio.sleep(WAIT_TIME)
+ payload = await request.json()
+ return web.json_response(payload)
+
+
+app = web.Application()
+setup_cache(app)
+app.router.add_post("/", some_long_running_view)
+
+web.run_app(app)
+```
+
+# License
+
+This project is released under BSD license. Feel free
+
+# Source Code
+
+The latest developer version is available in a github repository:
+<https://github.com/cr0hn/aiohttp-cache>
+
+# Development environment
+
+1. docker-compose run tests
+
+
+%prep
+%autosetup -n aiohttp-cache-4.0.1
+
+%build
+%py3_build
+
+%install
+%py3_install
+install -d -m755 %{buildroot}/%{_pkgdocdir}
+if [ -d doc ]; then cp -arf doc %{buildroot}/%{_pkgdocdir}; fi
+if [ -d docs ]; then cp -arf docs %{buildroot}/%{_pkgdocdir}; fi
+if [ -d example ]; then cp -arf example %{buildroot}/%{_pkgdocdir}; fi
+if [ -d examples ]; then cp -arf examples %{buildroot}/%{_pkgdocdir}; fi
+pushd %{buildroot}
+if [ -d usr/lib ]; then
+ find usr/lib -type f -printf "/%h/%f\n" >> filelist.lst
+fi
+if [ -d usr/lib64 ]; then
+ find usr/lib64 -type f -printf "/%h/%f\n" >> filelist.lst
+fi
+if [ -d usr/bin ]; then
+ find usr/bin -type f -printf "/%h/%f\n" >> filelist.lst
+fi
+if [ -d usr/sbin ]; then
+ find usr/sbin -type f -printf "/%h/%f\n" >> filelist.lst
+fi
+touch doclist.lst
+if [ -d usr/share/man ]; then
+ find usr/share/man -type f -printf "/%h/%f.gz\n" >> doclist.lst
+fi
+popd
+mv %{buildroot}/filelist.lst .
+mv %{buildroot}/doclist.lst .
+
+%files -n python3-aiohttp-cache -f filelist.lst
+%dir %{python3_sitelib}/*
+
+%files help -f doclist.lst
+%{_docdir}/*
+
+%changelog
+* Wed May 31 2023 Python_Bot <Python_Bot@openeuler.org> - 4.0.1-1
+- Package Spec generated