Caching strategies
Learn about the caching strategies available for Gezy in Front-Commerce, including the `PerGezyCustomer` implementation and how to configure it for optimal performance.
PerGezyCustomer
The PerGezyCustomer implementation is a decorator that is specific to the Gezy
connector. It will decorate the existing caching strategies so that DataLoader
keys are specific to the current customer. We highly recommend to use it on Gezy
stores that have prices per customer, so they can leverage other caching
mechanisms (such as Redis).
It is possible to provide a default customer id to use as scope for guest users.
Here is a configuration example:
export default {
strategies: [
// The PerGezyCustomer strategy MUST be registered after a persistent cache implementation
// because it has no effect in the context of the default per-request in-memory caching.
{
implementation: "Redis",
supports: "*",
config: {
host: "127.0.0.1",
},
},
{
implementation: "PerGezyCustomer",
// Will scope all data from the CatalogProductPrices DataLoader with the customer id
// (and the secondary price grid variants) before they are transmitted to the previous
// strategy (Redis). Other dataLoaders will use Redis storage in a standard fashion.
supports: ["CatalogProductPrices", "CatalogProductPrices_*"],
config: {
defaultCustomerId: 0,
},
},
],
};
PerGezyCustomer ships with @front-commerce/gezy; no additional package is
required. This pattern is illustrated in the demo skeleton as an example of a
custom cache strategy — adopt it only if your project actually needs it.