21 Commits

Author SHA1 Message Date
Nik Stuckenbrock
5ba03ca6f5 Correct example in README.md 2024-07-19 15:07:23 +02:00
Charles Perrot-Minot
f203d23194 Switch from on_event to lifespan asynccontextmanager
on_event is now deprecated, and to be replaced with lifespan: https://fastapi.tiangolo.com/advanced/events/
2024-05-12 22:57:14 -07:00
Samuel Rigaud
9217c85d94 📝 Use create_some_model as a function 2023-08-20 01:27:10 +02:00
Martijn Pieters
b287f21043 📖 Copy-edit README (#168)
- Update workflow shields to point to new CI/CD pipeline, and link
  all shields to somewhere appropriate.
- Use product names instead of code-markup names.
- Edit for English grammar and style.
- Expand decorator argument table to add defaults
- Add more meaningful `Coder` and key builder examples and expand
  on what the default key builder does.
2023-05-17 11:34:40 +00:00
Martijn Pieters
915f3dd8f2 Add a cache status header to the response
The header name is configurable, and defaults to `X-FastAPI-Cache`,
the value is either `HIT` or `MISS`.

Note that the header is not set at all when the cache is disabled.
2023-05-14 17:03:57 +01:00
Martijn Pieters
23d439f83a Make backends store bytes instead of strings
This is, for the majority of backends, the native format anyway, and so
we save encoding and decoding when using the PickleCodec or if (in future)
a orjson Coder was to be added.

For the JsonCodec, the only thing that changed is the location where the
JSON data is encoded to bytes and decoded back again to a string.
2023-05-10 17:35:15 +01:00
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
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
Martijn Pieters
32acafa5e0 Correct type hint: namespace is not optional
The namespace argument is positional and will never be `None` so should
not be marked as Optional. It is always a string, and the default is
to pass in an empty string.
2023-04-27 16:11:59 +01:00
Charl P. Botha
d0c0885eae Add coverage 2022-10-14 21:59:51 +02:00
wanghao
5c6f819636 docs: quick start redis 2022-09-14 16:24:10 +08:00
long2ice
cb9259807e feat: make request and response optional 2022-09-10 20:06:37 +08:00
Jimmy
a40c54e9e7 Update README & add usage 2021-09-29 16:22:04 +02:00
Joe Flack
e397dcb16b Updated readme.md
Corrected some syntactically incorrect commands
2021-09-23 16:10:31 -04:00
heliumbrain
9e3c9816c5 Update README.md
Updated readme to reflect the changes in aioredis 2.0
2021-07-15 23:15:01 +02:00
Mikhail Kuznetcov
ba7276ba98 Update README.md
add other params description
2021-01-11 17:37:39 +01:00
Mikhail Kuznetcov
cdae610432 Update README.md
add explanation about expire
2021-01-10 16:26:41 +01:00
long2ice
3134e5f67c update README.md 2020-11-12 13:04:50 +08:00
long2ice
c0259bc699 Add in-memory support. 2020-10-08 15:10:34 +08:00
long2ice
800032c46b update README.md 2020-08-27 09:27:52 +08:00
long2ice
c20bb73f27 first commit 2020-08-26 18:04:57 +08:00