-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Improve git handler and introduce caching
- Loading branch information
1 parent
72a2860
commit 90f51f1
Showing
11 changed files
with
276 additions
and
219 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# SPDX-FileCopyrightText: Copyright DB InfraGO AG and contributors | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
|
||
import abc | ||
|
||
|
||
class Cache(abc.ABC): | ||
@abc.abstractmethod | ||
def get(self, key: str) -> bytes | None: | ||
pass | ||
|
||
@abc.abstractmethod | ||
def set(self, key: str, value: bytes) -> None: | ||
pass | ||
|
||
@abc.abstractmethod | ||
def delete(self, key: str) -> None: | ||
pass | ||
|
||
@abc.abstractmethod | ||
def clear(self) -> None: | ||
pass | ||
|
||
|
||
class InMemoryCache(Cache): | ||
def __init__(self) -> None: | ||
self.cache: dict[str, bytes] = {} | ||
|
||
def get(self, key: str) -> bytes | None: | ||
return self.cache.get(key, None) | ||
|
||
def set(self, key: str, value: bytes) -> None: | ||
self.cache[key] = value | ||
|
||
def delete(self, key: str) -> None: | ||
self.cache.pop(key) | ||
|
||
def clear(self) -> None: | ||
self.cache.clear() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.