kvstore impls for redis / sqlite moved

This commit is contained in:
Ashwin Bharambe 2024-09-20 19:55:44 -07:00
parent c1ab66f1e6
commit 61974e337f
16 changed files with 137 additions and 114 deletions

View file

@ -0,0 +1,28 @@
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the terms described in the LICENSE file in
# the root directory of this source tree.
from datetime import datetime
from typing import Any, List, Optional, Protocol
from pydantic import BaseModel
class KVStoreValue(BaseModel):
key: str
value: Any
expiration: Optional[datetime] = None
class KVStore(Protocol):
async def set(
self, key: str, value: Any, expiration: Optional[datetime] = None
) -> None: ...
async def get(self, key: str) -> Optional[KVStoreValue]: ...
async def delete(self, key: str) -> None: ...
async def range(self, start_key: str, end_key: str) -> List[KVStoreValue]: ...