Skip to content

Commit

Permalink
feat: implement SupportedStorage abstract storage and MemoryStorage s…
Browse files Browse the repository at this point in the history
…torage
  • Loading branch information
leynier committed Oct 17, 2021
1 parent 8c64876 commit 044efe8
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions gotrue/lib/storage.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
from abc import ABC, abstractmethod
from typing import Dict, Optional


class SupportedStorage(ABC):
@abstractmethod
def get_item(self, key: str) -> Optional[str]:
...

@abstractmethod
def set_item(self, key: str, value: str) -> None:
...

@abstractmethod
def remove_item(self, key: str) -> None:
...


class MemoryStorage(SupportedStorage):
def __init__(self):
self.storage: Dict[str, str] = {}

def get_item(self, key: str) -> Optional[str]:
return self.storage.get(key)

def set_item(self, key: str, value: str) -> None:
self.storage[key] = value

def remove_item(self, key: str) -> None:
del self.storage[key]

0 comments on commit 044efe8

Please sign in to comment.