-
-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
upgrade CacheControl to use the more memory-efficient SeparateBodyFil…
…eCache Closes: #598
- Loading branch information
Showing
8 changed files
with
39 additions
and
34 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 |
---|---|---|
@@ -1,5 +1,12 @@ | ||
from datetime import datetime | ||
from typing import IO | ||
|
||
class BaseCache: | ||
def get(self, key: str) -> bytes | None: ... | ||
def set(self, key: str, value: bytes, expires: int | None = None) -> None: ... | ||
def set(self, key: str, value: bytes, expires: int | datetime | None = None) -> None: ... | ||
def delete(self, key: str) -> None: ... | ||
def close(self) -> None: ... | ||
|
||
class SeparateBodyBaseCache(BaseCache): | ||
def set_body(self, key: str, body: bytes) -> None: ... | ||
def get_body(self, key: str) -> IO[bytes] | None: ... |
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 |
---|---|---|
@@ -1,11 +1,3 @@ | ||
# Stubs for cachecontrol.caches (Python 2) | ||
# | ||
# NOTE: This dynamically typed stub was automatically generated by stubgen. | ||
from cachecontrol.caches.file_cache import SeparateBodyFileCache as SeparateBodyFileCache | ||
|
||
from typing import Any | ||
|
||
from .file_cache import FileCache as FileCache | ||
|
||
# from .redis_cache import RedisCache as RedisCache | ||
|
||
notice = ... # type: Any | ||
__all__ = ["SeparateBodyFileCache"] |
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 |
---|---|---|
@@ -1,31 +1,34 @@ | ||
from os import PathLike | ||
from typing import ContextManager | ||
|
||
from ..cache import BaseCache as BaseCache | ||
from ..controller import CacheController as CacheController | ||
from cachecontrol.cache import SeparateBodyBaseCache | ||
from datetime import datetime | ||
from filelock import BaseFileLock | ||
from pathlib import Path | ||
from typing import IO, ContextManager | ||
|
||
class _LockClass: | ||
path: str | ||
|
||
_lock_class = ContextManager[_LockClass] | ||
|
||
class FileCache(BaseCache): | ||
class _FileCacheMixin: | ||
directory: str | ||
forever: bool | ||
filemode: int | ||
dirmode: int | ||
lock_class: _lock_class | None = None | ||
def __init__( | ||
self, | ||
directory: str | PathLike[str], | ||
forever: bool = ..., | ||
filemode: int = ..., | ||
dirmode: int = ..., | ||
use_dir_lock: bool | None = ..., | ||
lock_class: _lock_class | None = ..., | ||
directory: str | Path, | ||
forever: bool = False, | ||
filemode: int = 384, | ||
dirmode: int = 448, | ||
lock_class: type[BaseFileLock] | None = None, | ||
) -> None: ... | ||
@staticmethod | ||
def encode(x: str) -> str: ... | ||
def get(self, key: str) -> None | bytes: ... | ||
def set(self, key: str, value: bytes, expires: int | None = None) -> None: ... | ||
def get(self, key: str) -> bytes | None: ... | ||
def set(self, key: str, value: bytes, expires: int | datetime | None = None) -> None: ... | ||
|
||
class SeparateBodyFileCache(_FileCacheMixin, SeparateBodyBaseCache): | ||
def get_body(self, key: str) -> IO[bytes] | None: ... | ||
def set_body(self, key: str, body: bytes) -> None: ... | ||
def delete(self, key: str) -> None: ... |
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