23 lines
450 B
Python
23 lines
450 B
Python
from abc import ABC, abstractmethod
|
|
|
|
|
|
class Storage(ABC):
|
|
@abstractmethod
|
|
def save(self, key: str, value: str) -> None:
|
|
pass
|
|
|
|
@abstractmethod
|
|
def load(self, key: str) -> str:
|
|
pass
|
|
|
|
|
|
class MemoryStorage(Storage):
|
|
def __init__(self):
|
|
self.storage = {}
|
|
|
|
def save(self, key: str, value: str) -> None:
|
|
self.storage[key] = value
|
|
|
|
def load(self, key: str) -> str:
|
|
return self.storage[key]
|