mirror of
https://github.com/kennethreitz/replit-py.git
synced 2026-06-05 23:10:18 +00:00
Delete FileCache in favor of simple dict
This commit is contained in:
@@ -2,50 +2,7 @@
|
||||
import flask
|
||||
|
||||
|
||||
class FileCache:
|
||||
"""A simple cache for files."""
|
||||
|
||||
def __init__(self) -> None:
|
||||
"""Initialize the class."""
|
||||
self.data = {}
|
||||
|
||||
def add_to_cache(self, filename: str, content: str) -> None:
|
||||
"""Add a filename to the cache.
|
||||
|
||||
Args:
|
||||
filename (str): The filename to add.
|
||||
content (str): The content to add to the cache.
|
||||
"""
|
||||
self.data[filename] = content
|
||||
|
||||
def has(self, filename: str) -> bool:
|
||||
"""Whether the cache has a certain filename.
|
||||
|
||||
Args:
|
||||
filename (str): The filename to check for.
|
||||
|
||||
Returns:
|
||||
bool: Whether the cache has filename.
|
||||
"""
|
||||
return filename in self.data
|
||||
|
||||
def invalidate(self, filename: str) -> None:
|
||||
"""Remove a filename from the cache.
|
||||
|
||||
Args:
|
||||
filename (str): The filename to remove.
|
||||
"""
|
||||
try:
|
||||
self.data.pop(filename)
|
||||
except KeyError:
|
||||
pass
|
||||
|
||||
def flush(self) -> None:
|
||||
"""Remove all values from the cache."""
|
||||
self.data = {}
|
||||
|
||||
|
||||
cache = FileCache()
|
||||
cache = {}
|
||||
|
||||
|
||||
class File(flask.Response):
|
||||
|
||||
Reference in New Issue
Block a user