Skip to content
This repository was archived by the owner on May 5, 2025. It is now read-only.

Commit ee419b2

Browse files
authored
Add MemoryStorage support (#160)
* Update docstring for storage_adapter * Add support for MemoryStorage
1 parent eb835ce commit ee419b2

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

pan_cortex_data_lake/adapters/tinydb_adapter.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
from threading import RLock
88

99
from tinydb import TinyDB, Query
10+
from tinydb.storages import MemoryStorage
1011

1112
from .. import CortexError
1213
from . import StorageAdapter
@@ -16,6 +17,7 @@ class TinyDBStore(StorageAdapter):
1617
def __init__(self, **kwargs):
1718
self._storage_params = kwargs.get("storage_params") or {}
1819
self.dbfile = self._storage_params.get("dbfile")
20+
self.memory_storage = self._storage_params.get("memory_storage", False)
1921
self.query = Query()
2022
self.db = self.init_store()
2123
self.lock = RLock()
@@ -36,6 +38,8 @@ def fetch_credential(self, credential=None, profile=None):
3638
return q.get(credential)
3739

3840
def init_store(self):
41+
if self.memory_storage is True:
42+
return TinyDB(storage=MemoryStorage)
3943
if self.dbfile:
4044
dbfile = self.dbfile
4145
elif os.getenv("PAN_CREDENTIALS_DBFILE"):

pan_cortex_data_lake/credentials.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ def __init__(
8383
region (str): Region. Defaults to ``None``.
8484
refresh_token (str): OAuth2 refresh token. Defaults to ``None``.
8585
scope (str): OAuth2 scope. Defaults to ``None``.
86+
storage_adapter (str): Namespace path to storage adapter module. Defaults to "pan_cortex_data_lake.adapters.tinydb_adapter.TinyDBStore".
8687
storage_params (dict) = Storage adapter parameters. Defaults to ``None``.
8788
token_url (str): Refresh URL. Defaults to ``None``.
8889
token_revoke_url (str): Revoke URL. Defaults to ``None``.

0 commit comments

Comments
 (0)