cache.js
* @author Hermann Mayer <hermann.mayer92@gmail.com>
* Build an cache key by given arguments.
* @param {Object} args - Method arguments to build an key of
CacheHelper.prototype.key = function(args)
// The first parameter of args could be an request
// Search it for request meta-data
if ('object' === typeof args[0] && args[0].hasOwnProperty('url')) {
// Search the request for service meta-data
if (firstIsRequest && args[0].hasOwnProperty('service')) {
key += args[idx].service.name + ':';
key += args[idx].service.method + ':';
// Build of all given arguments an cache key
Object.keys(args).forEach(function(idx) {
// Skip the first parameter if it is a request object
if (0 === idx && firstIsRequest) {
// Skip functions for key hashing
if ('function' === typeof args[idx]) {
if ('object' === typeof args[idx]) {
return argsValues.push(JSON.stringify(args[idx]));