Skip to content

Commit e5fd2ba

Browse files
client restructured
1 parent 290b44d commit e5fd2ba

7 files changed

Lines changed: 46 additions & 14 deletions

File tree

build_and_push.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
# Configuration
44
PACKAGE_NAME="montycat"
5-
VERSION="0.1.40"
5+
VERSION="0.1.41"
66
PYPI_TOKEN="${PYPI_TOKEN:-}"
77

88
# Exit on any error

montycat/core/engine.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,9 @@ async def create_store(self, persistent: bool = False) -> Any:
9595
bool
9696
"""
9797
return await self._execute_query_with_credentials([
98-
'create-store', "store", self.store, "persistent", "y" if persistent else "n"
98+
'create-store', "store", self.store, "persistent", "y" if persistent else "n",
9999
])
100-
100+
101101
async def remove_store(self, persistent: bool = False) -> Any:
102102
"""
103103
Removes an existing data store from the server.

montycat/core/store.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,8 @@ class Persistent(generic_kv, persistent_kv):
8080
Attributes:
8181
persistent (bool): Always True for persistent stores.
8282
distributed (bool): Always False for the basic persistent store.
83+
cache (Union[int, None]): Optional cache size for the store. Should be setup in MB. If parameter was not set default value (10 MB) will be used.
84+
compression (bool): Indicates whether data compression is enabled. Default is False.
8385
8486
Methods:
8587
__init__: Initializes the persistent store, inheriting from `generic_kv`.

montycat/store_classes/inmemory.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,4 +171,14 @@ async def get_keys(cls):
171171
cls.command = "get_keys"
172172

173173
query = convert_to_binary_query(cls)
174+
return await cls._run_query(query)
175+
176+
@classmethod
177+
async def create_keyspace(cls):
178+
179+
query = orjson.dumps({
180+
"raw": ["create-keyspace", "store", cls.store, "keyspace", cls.keyspace, "persistent", "y" if cls.persistent else "n"],
181+
"credentials": [cls.username, cls.password]
182+
})
183+
174184
return await cls._run_query(query)

montycat/store_classes/kv.py

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -278,16 +278,6 @@ def connect_engine(cls, engine: Engine) -> None:
278278
cls.port = engine.port
279279
cls.store = engine.store
280280

281-
@classmethod
282-
async def create_keyspace(cls):
283-
284-
query = orjson.dumps({
285-
"raw": ["create-keyspace", "store", cls.store, "keyspace", cls.keyspace, "persistent", "y" if cls.persistent else "n"],
286-
"credentials": [cls.username, cls.password]
287-
})
288-
289-
return await cls._run_query(query)
290-
291281
@classmethod
292282
async def remove_keyspace(cls):
293283

montycat/store_classes/persistent.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
from ..core.engine import send_data
22
from ..store_functions.store_generic_functions import convert_to_binary_query, convert_custom_key, handle_limit
33
from typing import Union
4+
import orjson
45

56
class persistent_kv:
7+
68
persistent: bool = True
9+
cache: Union[int, None] = None
10+
compression: bool = False
711

812
@classmethod
913
async def _run_query(cls, query: str):
@@ -125,4 +129,30 @@ async def get_keys(cls, limit: Union[list, int] = []):
125129
cls.command = "get_keys"
126130

127131
query = convert_to_binary_query(cls)
132+
return await cls._run_query(query)
133+
134+
@classmethod
135+
async def create_keyspace(cls):
136+
137+
query = orjson.dumps({
138+
"raw": ["create-keyspace", "store", cls.store, "keyspace", cls.keyspace, "persistent", "y", "cache", cls.cache if cls.cache else None, "compression", "y" if cls.compression else "n"],
139+
"credentials": [cls.username, cls.password]
140+
})
141+
142+
return await cls._run_query(query)
143+
144+
@classmethod
145+
async def update_cache_and_compression(cls):
146+
"""
147+
Updates the cache size and compression settings for the current store.
148+
149+
Returns:
150+
bool
151+
"""
152+
153+
query = orjson.dumps({
154+
"raw": ['update-cache-compression', "store", cls.store, "keyspace", cls.keyspace, "persistent", "y", "cache", cls.cache if cls.cache else None, "compression", "y" if cls.compression else "n"],
155+
"credentials": [cls.username, cls.password]
156+
})
157+
128158
return await cls._run_query(query)

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
setup(
44
name='montycat',
5-
version='0.1.40',
5+
version='0.1.41',
66
description='A Python client for MontyCat, NoSQL store utilizing Data Mesh architecture.',
77
packages=find_packages(),
88
zip_safe=False,

0 commit comments

Comments
 (0)