1 """Managers for each table."""
3 from __future__
import annotations
5 from typing
import TYPE_CHECKING, Any
12 from ..core
import Recorder
16 """Base class for table managers."""
18 _id_map: LRU[EventType[Any] | str, int]
20 def __init__(self, recorder: Recorder) ->
None:
21 """Initialize the table manager.
23 The table manager is responsible for managing the id mappings
24 for a table. When data is committed to the database, the
25 manager will move the data from the pending to the id map.
28 self._pending: dict[EventType[Any] | str, _DataT] = {}
31 """Resolve data to the id without accessing the underlying database.
33 This call is not thread-safe and must be called from the
36 return self._id_map.
get(data)
38 def get_pending(self, shared_data: EventType[Any] | str) -> _DataT |
None:
39 """Get pending data that have not be assigned ids yet.
41 This call is not thread-safe and must be called from the
44 return self._pending.
get(shared_data)
47 """Reset after the database has been reset or changed.
49 This call is not thread-safe and must be called from the
57 """Base class for LRU table managers."""
59 def __init__(self, recorder: Recorder, lru_size: int) ->
None:
60 """Initialize the LRU table manager.
62 We keep track of the most recently used items
63 and evict the least recently used items when the cache is full.
69 """Adjust the LRU cache size.
71 This call is not thread-safe and must be called from the
75 if new_size > lru.get_size():
76 lru.set_size(new_size)
None adjust_lru_size(self, int new_size)
None __init__(self, Recorder recorder, int lru_size)
None __init__(self, Recorder recorder)
_DataT|None get_pending(self, EventType[Any]|str shared_data)
int|None get_from_cache(self, str data)
web.Response get(self, web.Request request, str config_key)