Skip to content

Commit 6d72278

Browse files
committed
Cache methods separately based on the type of the argument.
1 parent 89ccff3 commit 6d72278

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

django_unicorn/call_method_parser.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ def _get_expr_string(expr: ast.expr) -> str:
6363
return expr_str
6464

6565

66-
@lru_cache(maxsize=128)
66+
@lru_cache(maxsize=128, typed=True)
6767
def eval_value(value):
6868
"""
6969
Uses `ast.literal_eval` to parse strings into an appropriate Python primative.
@@ -88,7 +88,7 @@ def eval_value(value):
8888
return value
8989

9090

91-
@lru_cache(maxsize=128)
91+
@lru_cache(maxsize=128, typed=True)
9292
def parse_kwarg(kwarg: str, raise_if_unparseable=False) -> Dict[str, Any]:
9393
"""
9494
Parses a potential kwarg as a string into a dictionary.
@@ -129,7 +129,7 @@ def parse_kwarg(kwarg: str, raise_if_unparseable=False) -> Dict[str, Any]:
129129
raise InvalidKwarg(f"'{kwarg}' could not be parsed")
130130

131131

132-
@lru_cache(maxsize=128)
132+
@lru_cache(maxsize=128, typed=True)
133133
def parse_call_method_name(call_method_name: str) -> Tuple[str, List[Any]]:
134134
"""
135135
Parses the method name from the request payload into a set of parameters to pass to a method.

django_unicorn/serializer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ def _fix_floats(current: Dict, data: Dict = None, paths: List = []) -> None:
175175
_piece = _piece[path]
176176

177177

178-
@lru_cache(maxsize=128)
178+
@lru_cache(maxsize=128, typed=True)
179179
def _dumps(serialized_data):
180180
dict_data = orjson.loads(serialized_data)
181181
_fix_floats(dict_data)

0 commit comments

Comments
 (0)