moleculerjs / moleculerjs/rfcs
Service-level cacher
Nobody has claimed this yet.
- Dominant language
- No language data
- Stars
- 2
- Forks
- 4
- PR merge metrics
- No merged PRs in 30d
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
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reviewing the broker-level cacher configuration, the service schema used by createService, and how action-level cache settings are handled. Define the service-level behavior for the MemoryLRU and Redis examples, including how different services select implementations; the issue currently provides no files, tests, or completed design sections to identify a concrete validation path.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- backend, distributed-systems
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100