MCPcopy Create free account
hub / github.com/Freedium-cfd/web / push

Method push

database-lib/database_lib/main.py:187–204  ·  view source on GitHub ↗
(self, key: str, value: Union[str, dict])

Source from the content-addressed store, hash-verified

185 return None
186
187 def push(self, key: str, value: Union[str, dict]) -> None:
188 if isinstance(value, dict):
189 try:
190 value = py_json.dumps(value)
191 except TypeError as e:
192 raise ValueError(f"Unable to serialize value to JSON: {e}")
193 elif not isinstance(value, str):
194 raise ValueError(
195 f"value argument should be a string or dict, not {type(value).__name__}"
196 )
197
198 self.ensure_connection()
199 with self.lock:
200 with self.connection:
201 self.cursor.execute(
202 "INSERT OR REPLACE INTO cache VALUES (:0, :1)",
203 {"0": key, "1": value},
204 )
205
206 def delete(self, key: str) -> None:
207 self.ensure_connection()

Callers 4

test_push_and_pullMethod · 0.45
test_deleteMethod · 0.45
test_all_lengthMethod · 0.45
test_randomMethod · 0.45

Calls 2

ensure_connectionMethod · 0.95
dumpsMethod · 0.45

Tested by 4

test_push_and_pullMethod · 0.36
test_deleteMethod · 0.36
test_all_lengthMethod · 0.36
test_randomMethod · 0.36