added more methods to AsyncPickleDB class

Commit 934eb46 · patx · 2025-02-08T22:20:52-05:00

Changeset
934eb4664099009bad2ee99d542458cedb5d92ef
Parents
2dbe2949deaee57ccfd9dc4aab08106241a0c1b9

View source at this commit

Comments

No comments yet.

Log in to comment

Diff

diff --git a/pickledb.py b/pickledb.py
index 5040531..0b2c426 100644
--- a/pickledb.py
+++ b/pickledb.py
@@ -275,3 +275,24 @@ class AsyncPickleDB(PickleDB):
             except Exception as e:
                 print(f"Failed to save database: {e}")
                 return False
+
+    async def aall(self):
+        """
+        Async version of the all method.
+
+        Returns:
+            list: A list of all keys.
+        """
+        async with self._lock:
+            return list(self.db.keys())
+
+    async def apurge(self):
+        """
+        Async version of the purge method.
+
+        Returns:
+            bool: True if the operation succeeds.
+        """
+        async with self._lock:
+            self.db.clear()
+            return True