Adds Surrogate Keys to named maps

This commit is contained in:
Raul Ochoa
2015-01-23 16:37:38 +01:00
parent 885accdadf
commit 272e8cd221
5 changed files with 113 additions and 11 deletions
+18
View File
@@ -0,0 +1,18 @@
var crypto = require('crypto');
function NamedMaps(owner, name) {
this.namespace = 'n';
this.owner = owner;
this.name = name;
}
module.exports = NamedMaps;
NamedMaps.prototype.key = function() {
return this.namespace + ':' + shortHashKey(this.owner + ':' + this.name);
};
function shortHashKey(target) {
return crypto.createHash('sha256').update(target).digest('base64').substring(0,6);
}