File tree Expand file tree Collapse file tree 2 files changed +31
-31
lines changed Expand file tree Collapse file tree 2 files changed +31
-31
lines changed Original file line number Diff line number Diff line change 11import sentry_sdk
2+ from sentry_sdk ._lru_cache import LRUCache
3+
4+ from typing import TYPE_CHECKING
5+
6+ if TYPE_CHECKING :
7+ from typing import TypedDict
8+
9+ FlagData = TypedDict ("FlagData" , {"flag" : str , "result" : bool })
10+
11+
12+ DEFAULT_FLAG_CAPACITY = 100
13+
14+
15+ class FlagBuffer :
16+
17+ def __init__ (self , capacity ):
18+ # type: (int) -> None
19+ self .buffer = LRUCache (capacity )
20+ self .capacity = capacity
21+
22+ def clear (self ):
23+ # type: () -> None
24+ self .buffer = LRUCache (self .capacity )
25+
26+ def get (self ):
27+ # type: () -> list[FlagData]
28+ return [{"flag" : key , "result" : value } for key , value in self .buffer .get_all ()]
29+
30+ def set (self , flag , result ):
31+ # type: (str, bool) -> None
32+ self .buffer .set (flag , result )
233
334
435def add_feature_flag (flag , result ):
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments