Martijn Pieters
e09ede2e4c
Inject dependencies using a namespace
...
Instead of assuming that the Request and Response injected keyword
arguments can be named `request` and `response`, use namespaced
keyword names starting with a double underscore.
By default the parameter names now start with `__fastapi_cache_` and so
are a) clearly marked as internal, and b) highly unlikely to clash with
existing keyword arguments. The prefix is configurable in the unlikely
event that the names would clash in specific cases.
2023-05-09 11:09:29 +01:00
Martijn Pieters
4cc946eb00
Fix handling non-GET requests
...
The `request` parameter being passed in was just a hold-over from an
earlier refactoring. Added tests to ensure that this edge case keeps
working.
2023-05-09 10:58:37 +01:00
Martijn Pieters
f78a599bbc
Decode cache data to the correct endpoint type
...
Use the return annotation to decode cached data to the correct type.
This follows the same logic FastAPI uses to JSON request bodies.
For the PickleCoder, this is a no-op as pickle already stores type
information in the serialised data.
2023-05-08 16:55:05 +01:00
long2ice
550ba76df4
Merge pull request #123 from mjpieters/method_signature
...
Attach updated endpoint signature to inner
2023-04-28 14:29:06 +08:00
Martijn Pieters
832650347b
Attach updated endpoint signature to inner
...
Not all endpoints accept a __signature__ attribute, nor should the
cache decorator modify the decorated endpoint. Attach the signature
to the returned inner function instead.
While here, refactor the signature updating code, and extract it to
a separate function.
2023-04-27 18:14:59 +01:00
Martijn Pieters
9c966286b4
Use complete type hints with all generic parameters filled
...
This makes the core fastapi_cache pass all strict type checker tests.
2023-04-27 16:31:42 +01:00
Martijn Pieters
a52f6b1406
Simplify key_builder calling
...
The keybuilder is either returning a string, or a coroutine or other
awaitable. If the latter, await on the return value to get the string.
2023-04-27 16:29:10 +01:00
Martijn Pieters
255f40117b
Define keybuilder protocol
...
This lets others create key builders that are type checked fully.
2023-04-27 16:26:41 +01:00
long2ice
27acce3160
ci: fix poetry
2023-02-15 10:45:19 +08:00
Naoki Shima
01c895dbbb
Support functions with VAR_KEYWORD parameter
...
decorating function with **kwargs parameter with @cache causes ValueError.
ValueError: wrong parameter order: variadic keyword parameter before keyword-only parameter
We need to inject request / response parameters before VAR_KEYWORD parameter.
2023-02-09 15:14:20 +09:00
long2ice
552a7695e8
Update fastapi_cache/decorator.py
...
Co-authored-by: mkdir700 <56359329+mkdir700@users.noreply.github.com >
2023-02-01 15:33:04 +08:00
hackjammer
ea1ffcd7b4
Add logging to decorator.py on backend failures
2023-01-17 12:15:53 +00:00
hackjammer
ab26fad604
passthrough for any type of backend exception
2023-01-15 17:07:37 +00:00
Tobias Schmocker
334b829a80
Merge branch 'master'
...
# Conflicts:
# fastapi_cache/decorator.py
2023-01-14 19:11:42 +01:00
long2ice
59a47b7fae
chore: set version 0.2.0
2023-01-11 21:20:41 +08:00
vvanglro
ed101595f7
fix: merge master
2023-01-11 16:43:36 +08:00
vvanglro
614ee25d0d
feat: merge master
2023-01-07 13:46:48 +08:00
hackjammer
b420f26e9b
transparent passthrough in the event of backend connection issues
2023-01-05 18:44:40 +00:00
long2ice
8f0920d0d7
ci: fix
2022-11-07 16:39:17 +08:00
vvanglro
a8fbf2b340
fix: request / router KeyError
2022-11-04 16:56:43 +08:00
long2ice
73f000a565
Merge pull request #93 from Mrreadiness/feat/type-hints-covering
...
Feat/type hints covering
2022-11-04 08:51:21 +08:00
long2ice
cda720f534
Merge pull request #74 from Genius-Voice/feature/support-async-keybuilder
...
Add ability to use async function for key_builder
2022-11-03 20:25:27 +08:00
Ivan Moiseev
5881bb9122
Merge branch 'main' into feat/type-hints-covering
...
# Conflicts:
# fastapi_cache/coder.py
# fastapi_cache/decorator.py
2022-11-03 15:53:22 +04:00
long2ice
671af52aea
Merge pull request #33 from DevLucca/master
...
add `no-cache` to cache exclusion
2022-10-31 21:51:35 +08:00
Ivan Moiseev
71a77f6b39
fix: request and response type hints
2022-10-30 11:03:16 +04:00
squaresmile
f3f134a318
Added typing to the decorator
2022-10-25 08:58:44 +07:00
Charl P. Botha
ceb70426f3
Factor out support for optional request / response
2022-10-14 21:58:34 +02:00
Charl P. Botha
d123ec4bfa
Add extra required await
2022-10-14 14:09:31 +02:00
Charl P. Botha
2822ab5d71
Factor out sync handling and use everywhere
2022-10-14 13:44:49 +02:00
long2ice
cb9259807e
feat: make request and response optional
2022-09-10 20:06:37 +08:00
Yurii Karabas
f310ef5b2d
Use run_in_threadpool instead of asyncio run_in_executor
2022-09-09 19:35:48 +03:00
Jegor Kitskerkin
6cc1e65abb
Add support for async key_builder
2022-08-11 15:16:12 +02:00
Lucca Marques
6dc449b830
Merge branch 'master' into master
2022-08-08 12:40:33 -03:00
Jegor Kitskerkin
d6c52408d2
Add support for normal def functions
2022-08-01 00:06:39 +02:00
Tobias Schmocker
e5250c7f58
remove private from cache-control
2022-02-04 16:41:42 +01:00
Tobias Schmocker
1795c048d1
add cache-control to response after setting the cache
2022-02-04 16:37:18 +01:00
long2ice
9928f4cda0
Add enable param to init
2021-10-28 15:52:21 +08:00
Lucca Leme Marques
dacd7e1b0f
add no-cache to cache exclusion
2021-08-23 11:51:28 -03:00
long2ice
fec3c78291
bug fix
2021-01-06 20:00:58 +08:00
long2ice
361a25857b
bug fix
2021-01-06 19:57:16 +08:00
long2ice
6f5d4900a9
bug fix
2021-01-06 14:41:46 +08:00
long2ice
7f7252d151
bug fix
2021-01-06 10:44:22 +08:00
long2ice
7f2ebfc494
Merge remote-tracking branch 'origin/master'
...
# Conflicts:
# fastapi_cache/decorator.py
# poetry.lock
2021-01-06 10:35:06 +08:00
long2ice
a42fdaf632
Fix cache key builder.
2021-01-06 10:34:30 +08:00
long2ice
75b4547963
add no-store
2020-12-28 20:04:09 +08:00
long2ice
dc2ac9cc90
Add default config when init
...
update JsonEncoder
2020-10-16 16:55:33 +08:00
long2ice
c0259bc699
Add in-memory support.
2020-10-08 15:10:34 +08:00
long2ice
c20bb73f27
first commit
2020-08-26 18:04:57 +08:00