Register "short" and "long" cache services
Overview -------- This is an improvement for developer-experience when working with caches. It reduces the amount of boilerplate required for core-code or extension-code in a typical caching use-case. Before ------ * To use a short-lived/latency-optimized cache (e.g. Redis or PHP array), you can work with the default cache instance (`Civi::cache('default')`. * To use a long-lived/durability-optimized cache (e.g. Redis or SQL), there is no simple way or code. You must [register a custom cache service](https://docs.civicrm.org/dev/en/latest/framework/cache/#example-named-service). After ----- * All the above remains true. Additionally, you can request the `short` or `long` cache service. * To use a short-lived/latency-optimized cache, you can use `Civi::cache('short')`. (`short` and `default` are synonmyms.) * To use a long-lived/durability-optimized cache, you can use use `Civi::cache('long')`. Comments -------- * After this is approved, we should update the [dev docs for caching](https://docs.civicrm.org/dev/en/latest/framework/cache/). * There's a bike-sheddy argument about the naming. I'd be willing to rename if there was a strong reason, but I don't really think there is a strong reason. This naming convention provides a simple dichotomy of `short` vs `long`.
Showing with 12 additions and 0 deletions