maleo-database 0.0.8__py3-none-any.whl → 0.0.10__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.
- maleo/database/config/additional.py +16 -18
- maleo/database/managers/client.py +23 -2
- {maleo_database-0.0.8.dist-info → maleo_database-0.0.10.dist-info}/METADATA +6 -6
- {maleo_database-0.0.8.dist-info → maleo_database-0.0.10.dist-info}/RECORD +7 -7
- {maleo_database-0.0.8.dist-info → maleo_database-0.0.10.dist-info}/WHEEL +0 -0
- {maleo_database-0.0.8.dist-info → maleo_database-0.0.10.dist-info}/licenses/LICENSE +0 -0
- {maleo_database-0.0.8.dist-info → maleo_database-0.0.10.dist-info}/top_level.txt +0 -0
@@ -3,21 +3,7 @@ from typing import Optional, TypeVar, Union
|
|
3
3
|
from maleo.enums.cache import Origin, Layer
|
4
4
|
from maleo.enums.expiration import Expiration
|
5
5
|
from maleo.types.base.string import OptionalString
|
6
|
-
|
7
|
-
|
8
|
-
class RedisCacheNamespaces(BaseModel):
|
9
|
-
base: str = Field(..., description="Base Redis's namespace")
|
10
|
-
|
11
|
-
def create(
|
12
|
-
self,
|
13
|
-
*ext: str,
|
14
|
-
origin: Origin,
|
15
|
-
layer: Layer,
|
16
|
-
base_override: OptionalString = None,
|
17
|
-
) -> str:
|
18
|
-
return ":".join(
|
19
|
-
[self.base if base_override is None else base_override, origin, layer, *ext]
|
20
|
-
)
|
6
|
+
from maleo.utils.cache import build_namespace as build_namespace_utils
|
21
7
|
|
22
8
|
|
23
9
|
class BaseAdditionalConfig(BaseModel):
|
@@ -31,6 +17,18 @@ class RedisAdditionalConfig(BaseAdditionalConfig):
|
|
31
17
|
ttl: Union[float, int] = Field(
|
32
18
|
Expiration.EXP_15MN.value, description="Time to live"
|
33
19
|
)
|
34
|
-
|
35
|
-
|
36
|
-
|
20
|
+
base_namespace: str = Field(..., description="Base namespace")
|
21
|
+
|
22
|
+
def build_namespace(
|
23
|
+
self,
|
24
|
+
*ext: str,
|
25
|
+
base: OptionalString = None,
|
26
|
+
client: OptionalString = None,
|
27
|
+
origin: Origin,
|
28
|
+
layer: Layer,
|
29
|
+
sep: str = ":",
|
30
|
+
) -> str:
|
31
|
+
base = base or self.base_namespace
|
32
|
+
return build_namespace_utils(
|
33
|
+
*ext, base=base, client=client, origin=origin, layer=layer, sep=sep
|
34
|
+
)
|
@@ -3,7 +3,8 @@ from motor.motor_asyncio import AsyncIOMotorClient
|
|
3
3
|
from pymongo import MongoClient
|
4
4
|
from redis.asyncio import Redis as AsyncRedis
|
5
5
|
from redis import Redis as SyncRedis
|
6
|
-
from typing import Generic, Literal, Tuple, TypeVar, Union, overload
|
6
|
+
from typing import Generic, Literal, Optional, Tuple, TypeVar, Union, overload
|
7
|
+
from maleo.types.base.string import ListOfStrings
|
7
8
|
from ..config import (
|
8
9
|
ElasticsearchDatabaseConfig,
|
9
10
|
MongoDBDatabaseConfig,
|
@@ -71,7 +72,27 @@ class MongoDBClientManager(
|
|
71
72
|
|
72
73
|
|
73
74
|
class RedisClientManager(ClientManager[RedisDatabaseConfig, AsyncRedis, SyncRedis]):
|
74
|
-
|
75
|
+
async def async_clear(self, prefixes: Optional[Union[ListOfStrings, str]] = None):
|
76
|
+
if prefixes is None:
|
77
|
+
prefixes = [self._config.additional.base_namespace]
|
78
|
+
|
79
|
+
if isinstance(prefixes, str):
|
80
|
+
prefixes = [prefixes]
|
81
|
+
|
82
|
+
for prefix in prefixes:
|
83
|
+
async for key in self._async_client.scan_iter(f"{prefix}*"):
|
84
|
+
await self._async_client.delete(key)
|
85
|
+
|
86
|
+
def sync_clear(self, prefixes: Optional[Union[ListOfStrings, str]] = None):
|
87
|
+
if prefixes is None:
|
88
|
+
prefixes = [self._config.additional.base_namespace]
|
89
|
+
|
90
|
+
if isinstance(prefixes, str):
|
91
|
+
prefixes = [prefixes]
|
92
|
+
|
93
|
+
for prefix in prefixes:
|
94
|
+
for key in self._sync_client.scan_iter(f"{prefix}*"):
|
95
|
+
self._sync_client.delete(key)
|
75
96
|
|
76
97
|
|
77
98
|
ClientManagerT = TypeVar(
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: maleo-database
|
3
|
-
Version: 0.0.
|
3
|
+
Version: 0.0.10
|
4
4
|
Summary: Database package for MaleoSuite
|
5
5
|
Author-email: Agra Bima Yuda <agra@nexmedis.com>
|
6
6
|
License: Proprietary
|
@@ -44,16 +44,16 @@ Requires-Dist: identify>=2.6.13
|
|
44
44
|
Requires-Dist: idna>=3.10
|
45
45
|
Requires-Dist: importlib_metadata>=8.7.0
|
46
46
|
Requires-Dist: maleo-constants>=0.0.6
|
47
|
-
Requires-Dist: maleo-dtos>=0.0.
|
47
|
+
Requires-Dist: maleo-dtos>=0.0.15
|
48
48
|
Requires-Dist: maleo-enums>=0.0.6
|
49
|
-
Requires-Dist: maleo-exceptions>=0.0.
|
50
|
-
Requires-Dist: maleo-logging>=0.0.
|
49
|
+
Requires-Dist: maleo-exceptions>=0.0.16
|
50
|
+
Requires-Dist: maleo-logging>=0.0.7
|
51
51
|
Requires-Dist: maleo-mixins>=0.0.13
|
52
|
-
Requires-Dist: maleo-schemas>=0.0.
|
52
|
+
Requires-Dist: maleo-schemas>=0.0.18
|
53
53
|
Requires-Dist: maleo-types-base>=0.0.2
|
54
54
|
Requires-Dist: maleo-types-controllers>=0.0.1
|
55
55
|
Requires-Dist: maleo-types-enums>=0.0.4
|
56
|
-
Requires-Dist: maleo-utils>=0.0.
|
56
|
+
Requires-Dist: maleo-utils>=0.0.5
|
57
57
|
Requires-Dist: motor>=3.7.1
|
58
58
|
Requires-Dist: mypy_extensions>=1.1.0
|
59
59
|
Requires-Dist: nodeenv>=1.9.1
|
@@ -2,12 +2,12 @@ maleo/database/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
2
|
maleo/database/dtos.py,sha256=DArPtSXzPJd896i-t4OmoqBP1mW-it8NVxvfWq7wq8Y,220
|
3
3
|
maleo/database/enums.py,sha256=vUPlePELTC30el9rUglQpc7ZYBVMKp3SiRHCZre9oQE,1693
|
4
4
|
maleo/database/config/__init__.py,sha256=6OK2FPbBiZdaEqhQ_Uu8g3h0jfwOvtwjoU8jZVdR70c,8607
|
5
|
-
maleo/database/config/additional.py,sha256=
|
5
|
+
maleo/database/config/additional.py,sha256=8uTEQDoKjAlXif-1njKuicIT07H_slTWr9pE0OENAU0,1098
|
6
6
|
maleo/database/config/connection.py,sha256=oMHIaom9PsGW0BpXW90bhuoFLNPsgQU4Fb8BateYjR4,22903
|
7
7
|
maleo/database/config/identifier.py,sha256=b1MjhoKl3h7xJe1eVIj1wjvYH9BrjHzKnjzdjaEaTeQ,626
|
8
8
|
maleo/database/config/pooling.py,sha256=Ms_7HjTrYathov2ef91L2rL7Ldgpr1p-7Fqg-1hv7m4,11556
|
9
9
|
maleo/database/managers/__init__.py,sha256=-rGAmqpPoNLaWeW7jEnINl7Dh3SbSu79PFNeifTvdHI,13710
|
10
|
-
maleo/database/managers/client.py,sha256=
|
10
|
+
maleo/database/managers/client.py,sha256=yfgnvdnKeWD4m_jGC8XKGq-UXpIG6zLm9V5SuyojwVU,3127
|
11
11
|
maleo/database/managers/engine.py,sha256=OYXxDhldbSevXDqod9joqXWaYgQ-NgF4YKPfUR5o9rM,1789
|
12
12
|
maleo/database/managers/session.py,sha256=QCyw1Um0xTmEGCHxX3kQ6z7Q_L2TT8Eq3_8NcpKIsxE,19000
|
13
13
|
maleo/database/orm/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
@@ -19,8 +19,8 @@ maleo/database/orm/models/mixins/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRk
|
|
19
19
|
maleo/database/orm/models/mixins/identifier.py,sha256=jICVsLUFw_f7TV_aX4KTTs_ycH35MRtRj5boTqctmZo,425
|
20
20
|
maleo/database/orm/models/mixins/status.py,sha256=Jzithn-Hl2ct1AqboGZSXrA35aaQEDvqtaB8oL7KIyo,376
|
21
21
|
maleo/database/orm/models/mixins/timestamp.py,sha256=TWqBTBvgSxcPsK0m7ggVrkHqzlqCM-2Zox7TAwCxd0I,1500
|
22
|
-
maleo_database-0.0.
|
23
|
-
maleo_database-0.0.
|
24
|
-
maleo_database-0.0.
|
25
|
-
maleo_database-0.0.
|
26
|
-
maleo_database-0.0.
|
22
|
+
maleo_database-0.0.10.dist-info/licenses/LICENSE,sha256=aftGsecnk7TWVX-7KW94FqK4Syy6YSZ8PZEF7EcIp3M,2621
|
23
|
+
maleo_database-0.0.10.dist-info/METADATA,sha256=vqcJsQkokXaui9r_D4TDtQaTfbSCNLBTdfEETge6wUg,3837
|
24
|
+
maleo_database-0.0.10.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
25
|
+
maleo_database-0.0.10.dist-info/top_level.txt,sha256=3Tpd1siVsfYoeI9FEOJNYnffx_shzZ3wsPpTvz5bljc,6
|
26
|
+
maleo_database-0.0.10.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|