// Backward compatible mode
this.broker.cacher.get(); // use the first cacher, in this case, the "Memory" cacher.
// New named path. Name comes from the lowercased type of cacher.
this.broker.cachers.memory.get();
this.broker.cachers.redis.get();
//posts.service.js
module.exports = {
name: "posts",
actions: {
list: {
// It will use the `this.broker.cachers.memory`
cache: {
cacher: "memory"
}
handler(ctx) {
/// ...
}
},
find: {
cache: {
// Set cacher by name
// It will use the `this.broker.cachers.redis`
cacher: "redis",
keys: ["limit", "offset", "#user.id"]
},
handler(ctx) {
/// ...
}
}
}
}
Motivation
In the big projects, certain services need a centralized Redis cacher but some simple services need only a local memory cacher. So, it would be good to add capabilities to ServiceBroker to support multiple cacher configuration.
Detailed design
This is the bulk of the RFC. Explain the design in enough detail for somebody
familiar with Vue to understand, and for somebody familiar with the
implementation to implement. This should get into specifics and corner-cases,
and include examples of how the feature is used. Any new terminology should be
defined here.
Drawbacks
Why should we not do this? Please consider:
implementation cost, both in term of code size and complexity
whether the proposed feature can be implemented in user space
the impact on teaching people Vue
integration of this feature with other existing and planned features
cost of migrating existing Vue applications (is it a breaking change?)
There are tradeoffs to choosing any path. Attempt to identify them here.
Alternatives
What other designs have been considered? What is the impact of not doing this?
Adoption strategy
If we implement this proposal, how will existing developers adopt it? Is
this a breaking change? Can we write a codemod? Can we provide a runtime adapter library for the original API it replaces?
Unresolved questions
Optional, but suggested for first drafts. What parts of the design are still
TBD?
Summary
Add multiple cacher configuration feature.
Examples
Example to define two cacher.
Access to the cachers:
Example to define two named cacher.
Access to the cachers:
Usage in services
Motivation
In the big projects, certain services need a centralized Redis cacher but some simple services need only a local memory cacher. So, it would be good to add capabilities to
ServiceBroker
to support multiple cacher configuration.Detailed design
This is the bulk of the RFC. Explain the design in enough detail for somebody familiar with Vue to understand, and for somebody familiar with the implementation to implement. This should get into specifics and corner-cases, and include examples of how the feature is used. Any new terminology should be defined here.
Drawbacks
Why should we not do this? Please consider:
There are tradeoffs to choosing any path. Attempt to identify them here.
Alternatives
What other designs have been considered? What is the impact of not doing this?
Adoption strategy
If we implement this proposal, how will existing developers adopt it? Is this a breaking change? Can we write a codemod? Can we provide a runtime adapter library for the original API it replaces?
Unresolved questions
Optional, but suggested for first drafts. What parts of the design are still TBD?