Source code for harp_apps.storage.services.blob_storages.memory

from harp.models import Blob
from harp_apps.storage.types import IBlobStorage


[docs] class MemoryBlobStorage(IBlobStorage): type = "memory"
[docs] def __init__(self): super().__init__() self._blobs = {}
[docs] async def get(self, blob_id: str): return self._blobs.get(blob_id, None)
[docs] async def put(self, blob: Blob) -> Blob: self._blobs[blob.id] = blob return blob
force_put = put
[docs] async def delete(self, blob_id: str): del self._blobs[blob_id]
[docs] async def exists(self, blob_id: str) -> bool: return False