sofa-hessian-node
Advanced tools
Comparing version 2.0.0 to 2.1.0
2.1.0 / 2020-07-01 | ||
================== | ||
**features** | ||
* [[`bd303c7`](http://github.com/sofastack/sofa-hessian-node/commit/bd303c74f4d23def37936a8f617747f5344b53a7)] - feat: every classMap will has own compileCache (#30) (陈峰 <<348018533@qq.com>>) | ||
2.0.0 / 2020-06-16 | ||
@@ -3,0 +9,0 @@ ================== |
@@ -9,2 +9,3 @@ 'use strict'; | ||
const codegen = require('@protobufjs/codegen'); | ||
const classMapCacheOn = Symbol('classMapCacheOn'); | ||
@@ -125,4 +126,20 @@ let cache = new Map(); | ||
/** | ||
* special key to determine the map structure logic | ||
* @param {Map<string, object>} classMap class data required for compile | ||
*/ | ||
function getCompileCache(classMap) { | ||
if (!cache.get(classMapCacheOn)) { | ||
return cache; | ||
} | ||
// If there is a special key, the cache uses the classmap dimension to establish a secondary cache structure. Different classmaps use different caches | ||
if (!cache.has(classMap)) { | ||
cache.set(classMap, new Map()); | ||
} | ||
return cache.get(classMap); | ||
} | ||
function compile(uniqueId, info, classMap, version, options) { | ||
let encodeFn = cache.get(uniqueId); | ||
const compileCache = getCompileCache(classMap); | ||
let encodeFn = compileCache.get(uniqueId); | ||
if (encodeFn) return encodeFn; | ||
@@ -255,3 +272,3 @@ | ||
} | ||
cache.set(uniqueId, encodeFn); | ||
compileCache.set(uniqueId, encodeFn); | ||
return encodeFn; | ||
@@ -269,1 +286,3 @@ } | ||
}; | ||
module.exports.classMapCacheOn = classMapCacheOn; |
@@ -9,2 +9,3 @@ 'use strict'; | ||
const codegen = require('@protobufjs/codegen'); | ||
const classMapCacheOn = Symbol('classMapCacheOn'); | ||
@@ -124,4 +125,20 @@ let cache = new Map(); | ||
/** | ||
* special key to determine the map structure logic | ||
* @param {Map<string, object>} classMap class data required for compile | ||
*/ | ||
function getCompileCache(classMap) { | ||
if (!cache.get(classMapCacheOn)) { | ||
return cache; | ||
} | ||
// If there is a special key, the cache uses the classmap dimension to establish a secondary cache structure. Different classmaps use different caches | ||
if (!cache.has(classMap)) { | ||
cache.set(classMap, new Map()); | ||
} | ||
return cache.get(classMap); | ||
} | ||
function compile(uniqueId, info, classMap, version, options) { | ||
let encodeFn = cache.get(uniqueId); | ||
const compileCache = getCompileCache(classMap); | ||
let encodeFn = compileCache.get(uniqueId); | ||
if (encodeFn) return encodeFn; | ||
@@ -250,3 +267,3 @@ | ||
} | ||
cache.set(uniqueId, encodeFn); | ||
compileCache.set(uniqueId, encodeFn); | ||
return encodeFn; | ||
@@ -262,1 +279,3 @@ } | ||
}; | ||
module.exports.classMapCacheOn = classMapCacheOn; |
{ | ||
"name": "sofa-hessian-node", | ||
"version": "2.0.0", | ||
"version": "2.1.0", | ||
"description": "An internal improved version of Hessian powered by Ant Financial.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
65121
1274
0