-
Notifications
You must be signed in to change notification settings - Fork 2
Open
Labels
Change: MinorModule: CacherModule: CoreStage: 2Feature is planned, it will be implementedFeature is planned, it will be implemented
Description
- Start Date: 2020-03-08
- Target Version: 0.14
- Reference Issues:
- Implementation PR:
Summary
We should add a new service-level cacher solution besides broker-based cacher. It can be useful when you don't want to use caching in all services, only just a few. In this case, you don't define cacher in broker options but in service schema instead.
Nevertheless, you can use different cacher implementations for different services.
Basic example
// Create broker
const broker = new ServiceBroker({
cacher: false
});
broker.createService({
name: "greeter",
// Service-level LRU cacher
cacher: {
type: "MemoryLRU",
options: {
max: 100,
ttl: 3
}
},
actions: {
hello: {
cache: true,
handler(ctx) {
return `Hello ${ctx.params.name}`;
}
}
}
});
broker.createService({
name: "products",
// Service-level Redis cacher
cacher: {
type: "Redis",
options: {
ttl: 30
}
},
actions: {
list: {
cache: true,
handler(ctx) {
return [];
}
}
}
});Detailed design
Drawbacks
Alternatives
Adoption strategy
Unresolved questions
Metadata
Metadata
Assignees
Labels
Change: MinorModule: CacherModule: CoreStage: 2Feature is planned, it will be implementedFeature is planned, it will be implemented