Skip to content

Commit b28b391

Browse files
committed
add a test route with varying arguments
Signed-off-by: Grant Ramsay <seapagan@gmail.com>
1 parent aa651fa commit b28b391

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

tests/live_test.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,3 +94,13 @@ def cache_invalid_type(request: Request, response: Response) -> logging.Logger:
9494
logger = logging.getLogger(__name__)
9595
logger.setLevel(logging.INFO)
9696
return logger
97+
98+
99+
@app.get("/cache_with_args/{user}")
100+
@cache_one_hour(tag="user_tag")
101+
def cache_with_args(user: int) -> dict[str, Union[bool, str]]:
102+
"""Have a varying cache key based on the user argument."""
103+
return {
104+
"success": True,
105+
"message": f"this data is for user {user}",
106+
}

tests/main.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,3 +63,13 @@ def cache_invalid_type(request: Request, response: Response) -> logging.Logger:
6363
logger = logging.getLogger(__name__)
6464
logger.setLevel(logging.INFO)
6565
return logger
66+
67+
68+
@app.get("/cache_with_args/{user}")
69+
@cache_one_hour(tag="user_tag")
70+
def cache_with_args(user: int) -> dict[str, Union[bool, str]]:
71+
"""Have a varying cache key based on the user argument."""
72+
return {
73+
"success": True,
74+
"message": f"this data is for user {user}",
75+
}

0 commit comments

Comments
 (0)