objbase 0.3.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- objbase/__init__.py +59 -0
- objbase/asyncio/__init__.py +0 -0
- objbase/asyncio/async_file_storage.py +40 -0
- objbase/asyncio/async_inventory.py +47 -0
- objbase/asyncio/async_mongodb_storage.py +46 -0
- objbase/asyncio/async_redis_storage.py +36 -0
- objbase/asyncio/async_sqlite_storage.py +19 -0
- objbase/asyncio/async_storage.py +18 -0
- objbase/asyncio/threaded_storage.py +30 -0
- objbase/errors.py +11 -0
- objbase/interface.py +27 -0
- objbase/inventory.py +59 -0
- objbase/py.typed +0 -0
- objbase/pydantic.py +123 -0
- objbase/storage/__init__.py +0 -0
- objbase/storage/file_storage.py +268 -0
- objbase/storage/inmemory_storage.py +51 -0
- objbase/storage/mongodb_storage.py +42 -0
- objbase/storage/redis_storage.py +68 -0
- objbase/storage/sqlite_storage.py +79 -0
- objbase/util/__init__.py +0 -0
- objbase/util/file_util.py +102 -0
- objbase/util/mongodb_util.py +45 -0
- objbase/util/redis_util.py +35 -0
- objbase-0.3.0.dist-info/METADATA +780 -0
- objbase-0.3.0.dist-info/RECORD +28 -0
- objbase-0.3.0.dist-info/WHEEL +4 -0
- objbase-0.3.0.dist-info/licenses/LICENSE +21 -0
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import os
|
|
2
|
+
from typing import TYPE_CHECKING
|
|
3
|
+
|
|
4
|
+
if TYPE_CHECKING:
|
|
5
|
+
import redis
|
|
6
|
+
import redis.asyncio
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def get_async_redis_client() -> "redis.asyncio.Redis":
|
|
10
|
+
try:
|
|
11
|
+
import redis.asyncio
|
|
12
|
+
except ImportError:
|
|
13
|
+
raise ImportError("redis is not installed. Please install it with 'pip install redis'.") from None
|
|
14
|
+
|
|
15
|
+
redis_url = os.getenv("REDIS_URL", "redis://localhost:6379/0")
|
|
16
|
+
if not redis_url:
|
|
17
|
+
raise ValueError("REDIS_URL is not set in environment variables.")
|
|
18
|
+
return redis.asyncio.from_url(redis_url, decode_responses=True)
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
# Backwards-compatible name; the standalone aioredis package is abandoned and
|
|
22
|
+
# has been merged into redis-py as redis.asyncio.
|
|
23
|
+
get_aioredis_client = get_async_redis_client
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
def get_redis_client() -> "redis.Redis":
|
|
27
|
+
try:
|
|
28
|
+
import redis
|
|
29
|
+
except ImportError:
|
|
30
|
+
raise ImportError("redis is not installed. Please install it with 'pip install redis'.") from None
|
|
31
|
+
|
|
32
|
+
redis_url = os.getenv("REDIS_URL", "redis://localhost:6379/0")
|
|
33
|
+
if not redis_url:
|
|
34
|
+
raise ValueError("REDIS_URL is not set in environment variables.")
|
|
35
|
+
return redis.from_url(redis_url, decode_responses=True)
|