Skip to content

Commit

Permalink
remove inefficient repetition of if
Browse files Browse the repository at this point in the history
  • Loading branch information
nomilous committed Jul 1, 2016
1 parent 8b0d204 commit 1814d2e
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lib/services/security/service.js
Original file line number Diff line number Diff line change
Expand Up @@ -202,40 +202,46 @@ SecurityService.prototype.onDataChanged = function(hook){

SecurityService.prototype.updateCaches = function(whatHappnd, changedData, additionalInfo){


// TODO: are these below in order of most common to least common?

if (whatHappnd == "upsert-user"){
this.__passwordCache.del(changedData.username);
this.__userCache.del(changedData.username);
return;
}

if (whatHappnd == "delete-user"){
this.__passwordCache.del(changedData.username);
this.__userCache.del(changedData.username);
return;
}

if (whatHappnd == "upsert-group"){
//clear users and passwords cache
this.__userCache = LRU(this.options.userCache);
this.__passwordCache = LRU(this.options.userCache);
return;
}

if (whatHappnd == "delete-group"){
this.__groupCache.del(changedData.name);
this.__userCache = LRU(this.options.userCache);
this.__passwordCache = LRU(this.options.userCache);
return;
}

if (whatHappnd == "unlink-group"){
//clear the user from the cache
this.__userCache.del(additionalInfo.username);
this.__passwordCache.del(additionalInfo.username);
return;
}

if (whatHappnd == "link-group"){
//clear the user from the cache
this.__userCache.del(additionalInfo.username);
this.__passwordCache.del(additionalInfo.username);
return;
}


Expand Down

0 comments on commit 1814d2e

Please sign in to comment.