Refactoring
This commit is contained in:
@ -1,3 +1,4 @@
|
||||
var crypto = require('crypto');
|
||||
|
||||
function Cache() {
|
||||
this._store = {};
|
||||
@ -20,14 +21,9 @@ Cache.prototype._serialize = function(mixedKey) {
|
||||
};
|
||||
|
||||
Cache.prototype._hash = function(str) {
|
||||
var hash = 0, i, chr, len;
|
||||
if (str.length === 0) return hash;
|
||||
for (i = 0, len = str.length; i < len; i++) {
|
||||
chr = str.charCodeAt(i);
|
||||
hash = ((hash << 5) - hash) + chr;
|
||||
hash |= 0; // Convert to 32bit integer
|
||||
}
|
||||
return hash;
|
||||
var shasum = crypto.createHash('md5');
|
||||
shasum.update(str);
|
||||
return shasum.digest('hex');
|
||||
};
|
||||
|
||||
module.exports = Cache;
|
||||
|
Reference in New Issue
Block a user