collections-cache 0.1.3__py3-none-any.whl → 0.1.4__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.
- collections_cache/collections_cache.py +28 -0
- {collections_cache-0.1.3.dist-info → collections_cache-0.1.4.dist-info}/METADATA +1 -1
- collections_cache-0.1.4.dist-info/RECORD +6 -0
- collections_cache-0.1.3.dist-info/RECORD +0 -6
- {collections_cache-0.1.3.dist-info → collections_cache-0.1.4.dist-info}/LICENSE +0 -0
- {collections_cache-0.1.3.dist-info → collections_cache-0.1.4.dist-info}/WHEEL +0 -0
@@ -3,6 +3,7 @@ from multiprocessing import Pool
|
|
3
3
|
from os import cpu_count, path, makedirs, scandir
|
4
4
|
from itertools import chain
|
5
5
|
from random import choice
|
6
|
+
#from threading import Thread as task
|
6
7
|
import pickle
|
7
8
|
|
8
9
|
class Collection_Cache:
|
@@ -56,6 +57,7 @@ class Collection_Cache:
|
|
56
57
|
return keys
|
57
58
|
|
58
59
|
def set_key(self, key, value):
|
60
|
+
"""Used to store values and associate a value with a key."""
|
59
61
|
if key not in self.keys_databases:
|
60
62
|
database_to_insert = choice(self.databases_list)
|
61
63
|
#print(f"Inserting in {database_to_insert}")
|
@@ -82,7 +84,13 @@ class Collection_Cache:
|
|
82
84
|
self.keys_databases[key] = database
|
83
85
|
#print(self.keys_databases)
|
84
86
|
|
87
|
+
def delete_to_keys_database(self, key):
|
88
|
+
"""Removes the key from the dictionary of stored keys"""
|
89
|
+
if key in self.keys_databases:
|
90
|
+
del self.keys_databases[key]
|
91
|
+
|
85
92
|
def get_key(self, key):
|
93
|
+
"""Used to obtain the value stored by the key"""
|
86
94
|
try:
|
87
95
|
database_to_search = self.keys_databases[key]
|
88
96
|
#print(database_to_search)
|
@@ -97,3 +105,23 @@ class Collection_Cache:
|
|
97
105
|
|
98
106
|
except Exception as error:
|
99
107
|
return error
|
108
|
+
|
109
|
+
def delete_key(self, key):
|
110
|
+
"""Used to delete the value stored by the key"""
|
111
|
+
try:
|
112
|
+
database_to_delete = self.keys_databases[key]
|
113
|
+
#print(database_to_search)
|
114
|
+
|
115
|
+
conn = sqlite3.connect(database_to_delete)
|
116
|
+
cursor = conn.cursor()
|
117
|
+
cursor.execute("PRAGMA journal_mode=WAL;")
|
118
|
+
cursor.execute("DELETE FROM data WHERE key = ?", (key,))
|
119
|
+
conn.commit()
|
120
|
+
conn.close()
|
121
|
+
self.delete_to_keys_database(key)
|
122
|
+
|
123
|
+
except KeyError:
|
124
|
+
return f"Key '{key}' not found."
|
125
|
+
|
126
|
+
except Exception as error:
|
127
|
+
return error
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: collections-cache
|
3
|
-
Version: 0.1.
|
3
|
+
Version: 0.1.4
|
4
4
|
Summary: Collection Cache is a Python package for managing data collections across multiple SQLite databases. It allows efficient storage, retrieval, and updating of key-value pairs, supporting various data types serialized with pickle. The package uses parallel processing for fast access and manipulation of large collections.
|
5
5
|
License: MIT
|
6
6
|
Author: Luiz-Trindade
|
@@ -0,0 +1,6 @@
|
|
1
|
+
collections_cache/__init__.py,sha256=uUp8lhp-HnZRumnU_8MT6qVq95t0pOzn7oLW7ARbnvc,48
|
2
|
+
collections_cache/collections_cache.py,sha256=8ZB0y8eJS1SFx8GEv-DQLlCyeqSL9VrNjRJz94gW_PE,4821
|
3
|
+
collections_cache-0.1.4.dist-info/LICENSE,sha256=RAIL-FmXSiNRgyiVlfhm2SvVI4XDVsN0jDt9207SJ8o,1168
|
4
|
+
collections_cache-0.1.4.dist-info/METADATA,sha256=uBO0-VHiAmD9shxP_9e4y6TI5Wi3gbvB6dGkodrtH_8,3199
|
5
|
+
collections_cache-0.1.4.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
|
6
|
+
collections_cache-0.1.4.dist-info/RECORD,,
|
@@ -1,6 +0,0 @@
|
|
1
|
-
collections_cache/__init__.py,sha256=uUp8lhp-HnZRumnU_8MT6qVq95t0pOzn7oLW7ARbnvc,48
|
2
|
-
collections_cache/collections_cache.py,sha256=Lqm9D-UAjPYHKc28yJtdpKpWORxrTGmg7t_1QCC8Pq4,3812
|
3
|
-
collections_cache-0.1.3.dist-info/LICENSE,sha256=RAIL-FmXSiNRgyiVlfhm2SvVI4XDVsN0jDt9207SJ8o,1168
|
4
|
-
collections_cache-0.1.3.dist-info/METADATA,sha256=96NFbdna6GVAYPOTbOi5kk13SOEaUwsHLUKEWMg-iAs,3199
|
5
|
-
collections_cache-0.1.3.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
|
6
|
-
collections_cache-0.1.3.dist-info/RECORD,,
|
File without changes
|
File without changes
|