... | ... | @@ -49,7 +49,7 @@ The current API routing scheme is simple, but disorganized, due to all API route |
|
|
|
|
|
### API Endpoint Caching
|
|
|
|
|
|
[Coldbox Event Caching](https://coldbox.ortusbooks.com/the-basics/event-handlers/event-caching) works by caching the literal output of an event in the Coldbox template cache (which, for inLeague, is in Redis). With any API-heavy application, this is a critical component to relieve pressure on the back-end API instance. There are two ways to implement event caching. For an example, look at the **authenticate** handler function **lookupUser**, a simple function that retrieves a user based on a username (which, for inLeague, is an email address). Note that this function is not an API endpoint: it is a helper function used by other API endpoints, like the `authenticate` `GET` endpoint that serves as our login handler.
|
|
|
[Coldbox Event Caching](https://coldbox.ortusbooks.com/the-basics/event-handlers/event-caching) works by caching the literal output of an event in the Coldbox template cache (which, for inLeague, is in Redis). With any API-heavy application, this is a critical component to relieve pressure on the back-end API instance. There are two ways to implement event caching. For an example, look at the **authenticate** handler function **lookupUser**, a simple function that retrieves a user based on a username (which, for inLeague, is an email address). *Very Important*: This function is not an API endpoint: it is a helper function used by other API endpoints, like the `authenticate` `GET` endpoint that serves as our login handler. *Do not ever cache API endpoints requiring any kind of authentication* because the relevant `aroundHandler` and interceptors do not fire when a Coldbox event is cached. This means that, for now, API endpoints should have two functions: an internal (private) `_endpoint()` event to go with the public `endpoint()` event, where only the private event is cached.
|
|
|
|
|
|
1. **Event function definition**: Specify `cache=true` and `cacheTimeout=someNumber` in the event, e.g.
|
|
|
|
... | ... | |