collections-cache 0.2.8.20250303__py3-none-any.whl → 0.2.9.20250303__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 +19 -11
- {collections_cache-0.2.8.20250303.dist-info → collections_cache-0.2.9.20250303.dist-info}/METADATA +1 -1
- collections_cache-0.2.9.20250303.dist-info/RECORD +6 -0
- collections_cache-0.2.8.20250303.dist-info/RECORD +0 -6
- {collections_cache-0.2.8.20250303.dist-info → collections_cache-0.2.9.20250303.dist-info}/LICENSE +0 -0
- {collections_cache-0.2.8.20250303.dist-info → collections_cache-0.2.9.20250303.dist-info}/WHEEL +0 -0
@@ -15,6 +15,8 @@ class Collection_Cache:
|
|
15
15
|
self.collection_dir = path.join("./Collections", self.collection_name)
|
16
16
|
self.databases_list = []
|
17
17
|
self.keys_databases = {}
|
18
|
+
self.temp_keys_values = {}
|
19
|
+
self.size_limit = 200
|
18
20
|
|
19
21
|
# Init methods
|
20
22
|
self.create_collection()
|
@@ -66,13 +68,22 @@ class Collection_Cache:
|
|
66
68
|
conn.close()
|
67
69
|
return keys
|
68
70
|
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
71
|
+
# Experimental
|
72
|
+
def verify_size_of_temp_queue(self, type_of_operation: str):
|
73
|
+
if type_of_operation == "set_key" and len(self.temp_keys_values) >= self.size_limit:
|
74
|
+
self.set_multi_keys(self.temp_keys_values)
|
75
|
+
self.temp_keys_values = {}
|
76
|
+
else:
|
77
|
+
self.set_multi_keys(self.temp_keys_values)
|
78
|
+
self.temp_keys_values = {}
|
74
79
|
|
80
|
+
# Experimental
|
75
81
|
def set_key(self, key: str, value: any):
|
82
|
+
"""Used to store values and associate a value with a key."""
|
83
|
+
self.temp_keys_values[key] = value
|
84
|
+
self.verify_size_of_temp_queue("set_key")
|
85
|
+
|
86
|
+
def set_key_exec(self, key: str, value: any):
|
76
87
|
"""Used to store values and associate a value with a key."""
|
77
88
|
if key not in self.keys_databases:
|
78
89
|
database_to_insert = choice(self.databases_list)
|
@@ -95,22 +106,20 @@ class Collection_Cache:
|
|
95
106
|
|
96
107
|
def set_multi_keys(self, keys_and_values: dict[str, any]):
|
97
108
|
"""Experimental. Set multiple keys and values at the same time."""
|
98
|
-
|
99
109
|
with Thread(self.cpu_cores) as thread:
|
100
|
-
thread.map(lambda kv: self.
|
110
|
+
thread.map(lambda kv: self.set_key_exec(kv[0], kv[1]), keys_and_values.items())
|
101
111
|
|
102
112
|
def add_to_keys_database(self, key, database):
|
103
113
|
self.keys_databases[key] = database
|
104
114
|
|
105
115
|
def delete_to_keys_database(self, key):
|
106
116
|
"""Removes the key from the dictionary of stored keys"""
|
107
|
-
|
108
117
|
if key in self.keys_databases:
|
109
118
|
del self.keys_databases[key]
|
110
119
|
|
111
120
|
def get_key(self, key: str):
|
112
121
|
"""Used to obtain the value stored by the key"""
|
113
|
-
|
122
|
+
self.verify_size_of_temp_queue("get_key")
|
114
123
|
try:
|
115
124
|
database_to_search = self.keys_databases[key]
|
116
125
|
conn = sqlite3.connect(database_to_search)
|
@@ -122,11 +131,10 @@ class Collection_Cache:
|
|
122
131
|
return pickle.loads(result[0][0])
|
123
132
|
|
124
133
|
except Exception as error:
|
125
|
-
return
|
134
|
+
return None
|
126
135
|
|
127
136
|
def delete_key(self, key: str):
|
128
137
|
"""Used to delete the value stored by the key"""
|
129
|
-
|
130
138
|
try:
|
131
139
|
database_to_delete = self.keys_databases[key]
|
132
140
|
conn = sqlite3.connect(database_to_delete)
|
{collections_cache-0.2.8.20250303.dist-info → collections_cache-0.2.9.20250303.dist-info}/METADATA
RENAMED
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: collections-cache
|
3
|
-
Version: 0.2.
|
3
|
+
Version: 0.2.9.20250303
|
4
4
|
Summary: collections-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=z9qQfnKFiO5sLf4py7o_FgviuPlOTFao3SJH7bKqhLo,5899
|
3
|
+
collections_cache-0.2.9.20250303.dist-info/LICENSE,sha256=RAIL-FmXSiNRgyiVlfhm2SvVI4XDVsN0jDt9207SJ8o,1168
|
4
|
+
collections_cache-0.2.9.20250303.dist-info/METADATA,sha256=WEyJDnHBpdRXpWLGsEmVnI--6MdZ8wSPCyJhi_a1N5M,4993
|
5
|
+
collections_cache-0.2.9.20250303.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
|
6
|
+
collections_cache-0.2.9.20250303.dist-info/RECORD,,
|
@@ -1,6 +0,0 @@
|
|
1
|
-
collections_cache/__init__.py,sha256=uUp8lhp-HnZRumnU_8MT6qVq95t0pOzn7oLW7ARbnvc,48
|
2
|
-
collections_cache/collections_cache.py,sha256=Yosw2599y3i1c9jDWYQuo25e9fTjU3rKuBTeE6DuV4E,5378
|
3
|
-
collections_cache-0.2.8.20250303.dist-info/LICENSE,sha256=RAIL-FmXSiNRgyiVlfhm2SvVI4XDVsN0jDt9207SJ8o,1168
|
4
|
-
collections_cache-0.2.8.20250303.dist-info/METADATA,sha256=zxCq5QF59ISG91zQZLs9tczwzs1HcCi8lW3L1EG6D_g,4993
|
5
|
-
collections_cache-0.2.8.20250303.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
|
6
|
-
collections_cache-0.2.8.20250303.dist-info/RECORD,,
|
{collections_cache-0.2.8.20250303.dist-info → collections_cache-0.2.9.20250303.dist-info}/LICENSE
RENAMED
File without changes
|
{collections_cache-0.2.8.20250303.dist-info → collections_cache-0.2.9.20250303.dist-info}/WHEEL
RENAMED
File without changes
|