You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
refactor: remove singleton pattern in storage and separate a pickle_io module
- Replaced singleton implementation in user_data with a shared data reference approach.
- Moved pickling functionality to a new module pickle_io for better separation of concerns.
- Reduced the complexity of error handling for pickle issue
- Updated `UserDataManager` to accept a custom save function for greater flexibility.
- Enhanced documentation for clarity on functionality and usage.
- Modified persistent_cache to utilize the pickle_io module
Copy file name to clipboardExpand all lines: src/mastermind/storage/persistent_cache.py
+11-17Lines changed: 11 additions & 17 deletions
Original file line number
Diff line number
Diff line change
@@ -1,14 +1,19 @@
1
1
importglob
2
2
importos
3
-
importpickle
4
3
fromtypingimportAny
5
4
5
+
frommastermind.storage.pickle_ioimport (
6
+
read_pickled_data,
7
+
write_pickled_data,
8
+
)
9
+
6
10
7
11
classPersistentCacheManager:
8
12
"""
9
13
Manages a persistent cache of Python objects on the file system.
10
14
11
-
The PersistentCacheManager class provides a simple interface for caching and retrieving data, using the pickle module to serialize and deserialize the objects.
15
+
The PersistentCacheManager class provides a simple interface for caching and retrieving data,
16
+
using the pickle_io module for pickling to serialize and deserialize the objects.
12
17
13
18
The cache files are stored in the "data" directory, which is created automatically if it does not exist.
0 commit comments