mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-09-08 17:13:45 +08:00
Revert "Comments... because Ill never remember this"
This reverts commit 07adabd70d.
This commit is contained in:
@@ -17,10 +17,6 @@ from openpilot.system.hardware import HARDWARE, PC
|
||||
BACKLIGHT_OFFROAD = 65 if HARDWARE.get_device_type() == "mici" else 50
|
||||
USBGPU_POLL_INTERVAL = 1.0
|
||||
class CachedParams:
|
||||
"""
|
||||
Global TTL-based cache for Params() to prevent excessive disk/IPC reads.
|
||||
Dynamically wraps read methods (get*) to cache values and write methods (put*) to invalidate stale cache.
|
||||
"""
|
||||
def __init__(self, ttl: float = 1.0):
|
||||
self._params = Params()
|
||||
self._cache = {}
|
||||
@@ -28,7 +24,6 @@ class CachedParams:
|
||||
self._ttl = ttl
|
||||
|
||||
def _invalidate(self, key=None):
|
||||
# Clears specific key or entire cache to guarantee fresh reads after writes
|
||||
if key is None:
|
||||
self._cache.clear()
|
||||
else:
|
||||
@@ -44,7 +39,6 @@ class CachedParams:
|
||||
return attr
|
||||
|
||||
if name.startswith("get"):
|
||||
# Intercept reads to serve from RAM if TTL is valid
|
||||
def get_wrapper(key, *args, **kwargs):
|
||||
now = time.monotonic()
|
||||
k_str = key.decode("utf-8") if isinstance(key, bytes) else str(key)
|
||||
@@ -59,7 +53,6 @@ class CachedParams:
|
||||
return get_wrapper
|
||||
|
||||
if name.startswith("put") or name.startswith("remove") or name.startswith("clear"):
|
||||
# Intercept writes to immediately invalidate stale data
|
||||
def put_wrapper(key=None, *args, **kwargs):
|
||||
res = attr(key, *args, **kwargs) if key is not None else attr(*args, **kwargs)
|
||||
self._invalidate(key)
|
||||
|
||||
Reference in New Issue
Block a user