This is an automated email from the ASF dual-hosted git repository.
huxing pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-dubbo-js.git
The following commit(s) were added to refs/heads/master by this push:
new 28dedc4 dubbo-invoker add cache
new a946e25 Merge pull request #110 from hufeng/master
28dedc4 is described below
commit 28dedc40b380ca41d3d609e80f67383c35f2eecd
Author: hufeng <[email protected]>
AuthorDate: Tue May 21 10:23:29 2019 +0800
dubbo-invoker add cache
---
packages/dubbo-invoker/src/matcher.ts | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/packages/dubbo-invoker/src/matcher.ts
b/packages/dubbo-invoker/src/matcher.ts
index 4f14a1e..1119a3e 100644
--- a/packages/dubbo-invoker/src/matcher.ts
+++ b/packages/dubbo-invoker/src/matcher.ts
@@ -28,6 +28,7 @@ const log = debug('dubbo:dubbo-invoker');
*/
export class Matcher {
private readonly _rules: Array<IRule> = [];
+ private readonly _cache: Map<string, IDubboInvokeParam> = new Map();
/**
* 匹配规则
@@ -55,6 +56,11 @@ export class Matcher {
//获取当前context的dubbo接口
const {dubboInterface} = ctx;
+ // get from cache
+ if (this._cache.has(dubboInterface)) {
+ return this._cache.get(dubboInterface);
+ }
+
for (let rule of this._rules) {
const {condition, invokeParam} = rule;