-
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 0a6a9fb
Showing
24 changed files
with
524 additions
and
414 deletions.
There are no files selected for viewing
25 changes: 25 additions & 0 deletions
25
...ab/alembic/versions/abddaf015966_add_repository_id_to_git_model_and_remove_unused_name.py
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,25 @@ | ||
# SPDX-FileCopyrightText: Copyright DB InfraGO AG and contributors | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
"""Add repository id to git model and remove unused git model name | ||
Revision ID: abddaf015966 | ||
Revises: 028c72ddfd20 | ||
Create Date: 2024-08-12 11:43:34.158404 | ||
""" | ||
import sqlalchemy as sa | ||
from alembic import op | ||
|
||
# revision identifiers, used by Alembic. | ||
revision = "abddaf015966" | ||
down_revision = "028c72ddfd20" | ||
branch_labels = None | ||
depends_on = None | ||
|
||
|
||
def upgrade(): | ||
op.add_column( | ||
"git_models", sa.Column("repository_id", sa.String(), nullable=True) | ||
) | ||
op.drop_column("git_models", "name") |
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
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.