summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCoprDistGit <infra@openeuler.org>2023-06-20 07:03:08 +0000
committerCoprDistGit <infra@openeuler.org>2023-06-20 07:03:08 +0000
commit27ff170d825ebff15b3ee87c0cd6c9549d789977 (patch)
tree9a2652e162a5f882a4396abadf885fd9a12b64ac
parent224cf60f18431c47be0dd23edce21bce25348c6a (diff)
automatic import of python-redis-decoratoropeneuler20.03
-rw-r--r--.gitignore1
-rw-r--r--python-redis-decorator.spec317
-rw-r--r--sources1
3 files changed, 319 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
index e69de29..64604b8 100644
--- a/.gitignore
+++ b/.gitignore
@@ -0,0 +1 @@
+/redis_decorator-0.4.tar.gz
diff --git a/python-redis-decorator.spec b/python-redis-decorator.spec
new file mode 100644
index 0000000..97d7ee0
--- /dev/null
+++ b/python-redis-decorator.spec
@@ -0,0 +1,317 @@
+%global _empty_manifest_terminate_build 0
+Name: python-redis-decorator
+Version: 0.4
+Release: 1
+Summary: Using redis as external redis_dec by one line of code
+License: MIT License
+URL: https://github.com/louisLouL/louisPy
+Source0: https://mirrors.aliyun.com/pypi/web/packages/14/20/6c916232c4fea1aaa6a993510e724d01f552ef806ef4ed43ecc98207c503/redis_decorator-0.4.tar.gz
+BuildArch: noarch
+
+Requires: python3-redis
+Requires: python3-pandas
+
+%description
+## Quick start
+### Install
+```bash
+pip install redis_decorator
+```
+
+### Initialize
+```python
+from redis_dec import Cache
+from redis import StrictRedis
+redis = StrictRedis(decode_responses=True)
+cache = Cache(redis)
+```
+## Examples
+Make sure you have redis up and running.(https://redis.io/)
+
+### Example1 : Cache string return
+
+```python
+from time import sleep
+from datetime import datetime
+@cache.ttl(300)
+def pseudo_calc():
+ sleep(1)
+ print("Computation in progress")
+ return str(datetime.now())
+
+for i in range(10):
+ print(pseudo_calc())
+```
+#### Example 2: Cache Pandas Dataframe
+```python
+# Set cache's time to live to 300 seconds (expires in 300 seconds)
+# If left blank, e.g. @cache.df(), cache will stay forever. Don't recommended.
+import pandas as pd
+@cache.df(300)
+def return_a_df(*args, **kwargs):
+ sleep(1)
+ print("Computation in progress")
+ return pd.DataFrame({"time": [str(datetime.now()) for _ in range(5)], "foo": list(range(5))})
+
+
+for i in range(5):
+ print(return_a_df(1, 5))
+```
+
+#### Example 3: Cache dict
+```python
+
+@cache.dict(60)
+def return_a_dict(*args, **kwargs):
+ sleep(1)
+ print("Computation in progress")
+ return {"now": str(datetime.now())}
+
+
+for i in range(5):
+ print(return_a_dict())
+```
+
+#### Example 4: Cache float number
+```python
+@cache.float(60)
+def return_a_float(*args, **kwargs):
+ return random()
+
+
+for i in range(5):
+ print(return_a_float())
+```
+
+#### Delete Cache
+```python
+# Delete cache by function and signature
+cache.delete_cache(return_a_float, 2, b=3)
+# Delete cache by function
+cache.delete_cache(return_a_float)
+# Delete all caches
+cache.delete_cache()
+```
+
+
+
+%package -n python3-redis-decorator
+Summary: Using redis as external redis_dec by one line of code
+Provides: python-redis-decorator
+BuildRequires: python3-devel
+BuildRequires: python3-setuptools
+BuildRequires: python3-pip
+%description -n python3-redis-decorator
+## Quick start
+### Install
+```bash
+pip install redis_decorator
+```
+
+### Initialize
+```python
+from redis_dec import Cache
+from redis import StrictRedis
+redis = StrictRedis(decode_responses=True)
+cache = Cache(redis)
+```
+## Examples
+Make sure you have redis up and running.(https://redis.io/)
+
+### Example1 : Cache string return
+
+```python
+from time import sleep
+from datetime import datetime
+@cache.ttl(300)
+def pseudo_calc():
+ sleep(1)
+ print("Computation in progress")
+ return str(datetime.now())
+
+for i in range(10):
+ print(pseudo_calc())
+```
+#### Example 2: Cache Pandas Dataframe
+```python
+# Set cache's time to live to 300 seconds (expires in 300 seconds)
+# If left blank, e.g. @cache.df(), cache will stay forever. Don't recommended.
+import pandas as pd
+@cache.df(300)
+def return_a_df(*args, **kwargs):
+ sleep(1)
+ print("Computation in progress")
+ return pd.DataFrame({"time": [str(datetime.now()) for _ in range(5)], "foo": list(range(5))})
+
+
+for i in range(5):
+ print(return_a_df(1, 5))
+```
+
+#### Example 3: Cache dict
+```python
+
+@cache.dict(60)
+def return_a_dict(*args, **kwargs):
+ sleep(1)
+ print("Computation in progress")
+ return {"now": str(datetime.now())}
+
+
+for i in range(5):
+ print(return_a_dict())
+```
+
+#### Example 4: Cache float number
+```python
+@cache.float(60)
+def return_a_float(*args, **kwargs):
+ return random()
+
+
+for i in range(5):
+ print(return_a_float())
+```
+
+#### Delete Cache
+```python
+# Delete cache by function and signature
+cache.delete_cache(return_a_float, 2, b=3)
+# Delete cache by function
+cache.delete_cache(return_a_float)
+# Delete all caches
+cache.delete_cache()
+```
+
+
+
+%package help
+Summary: Development documents and examples for redis-decorator
+Provides: python3-redis-decorator-doc
+%description help
+## Quick start
+### Install
+```bash
+pip install redis_decorator
+```
+
+### Initialize
+```python
+from redis_dec import Cache
+from redis import StrictRedis
+redis = StrictRedis(decode_responses=True)
+cache = Cache(redis)
+```
+## Examples
+Make sure you have redis up and running.(https://redis.io/)
+
+### Example1 : Cache string return
+
+```python
+from time import sleep
+from datetime import datetime
+@cache.ttl(300)
+def pseudo_calc():
+ sleep(1)
+ print("Computation in progress")
+ return str(datetime.now())
+
+for i in range(10):
+ print(pseudo_calc())
+```
+#### Example 2: Cache Pandas Dataframe
+```python
+# Set cache's time to live to 300 seconds (expires in 300 seconds)
+# If left blank, e.g. @cache.df(), cache will stay forever. Don't recommended.
+import pandas as pd
+@cache.df(300)
+def return_a_df(*args, **kwargs):
+ sleep(1)
+ print("Computation in progress")
+ return pd.DataFrame({"time": [str(datetime.now()) for _ in range(5)], "foo": list(range(5))})
+
+
+for i in range(5):
+ print(return_a_df(1, 5))
+```
+
+#### Example 3: Cache dict
+```python
+
+@cache.dict(60)
+def return_a_dict(*args, **kwargs):
+ sleep(1)
+ print("Computation in progress")
+ return {"now": str(datetime.now())}
+
+
+for i in range(5):
+ print(return_a_dict())
+```
+
+#### Example 4: Cache float number
+```python
+@cache.float(60)
+def return_a_float(*args, **kwargs):
+ return random()
+
+
+for i in range(5):
+ print(return_a_float())
+```
+
+#### Delete Cache
+```python
+# Delete cache by function and signature
+cache.delete_cache(return_a_float, 2, b=3)
+# Delete cache by function
+cache.delete_cache(return_a_float)
+# Delete all caches
+cache.delete_cache()
+```
+
+
+
+%prep
+%autosetup -n redis_decorator-0.4
+
+%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-redis-decorator -f filelist.lst
+%dir %{python3_sitelib}/*
+
+%files help -f doclist.lst
+%{_docdir}/*
+
+%changelog
+* Tue Jun 20 2023 Python_Bot <Python_Bot@openeuler.org> - 0.4-1
+- Package Spec generated
diff --git a/sources b/sources
new file mode 100644
index 0000000..ddddc9d
--- /dev/null
+++ b/sources
@@ -0,0 +1 @@
+d035c13fa0a9fef45f04de5c080ed67b redis_decorator-0.4.tar.gz