services/db.js
function put(key, value, testCacheEnabled) {
  const cacheEnabled = testCacheEnabled || CACHE_ENABLED;

  return postgres.put(key, value)
    .then((res) => {
      // persist to cache only if cache is set up/enabled, return postgres result regardless
      if (cacheEnabled) {
        return redis.put(key, value).then(() => res);
      }

      return res;
    });
}
function put(key, value, testCacheEnabled) {
  const cacheEnabled = testCacheEnabled || CACHE_ENABLED;

  return postgres.put(key, value)
    .then((res) => {
      // persist to cache only if cache is set up/enabled, return postgres result regardless
      if (cacheEnabled) {
        return redis.put(key, value).then(() => res);
      }

      return res;
    });
}
function put ( key , value , testCacheEnabled ) { const cacheEnabled = testCacheEnabled || CACHE_ENABLED ; return postgres . put ( key , value ) . then ( ( res ) => { // persist to cache only if cache is set up/enabled, return postgres result regardless if ( cacheEnabled ) { return redis . put ( key , value ) . then ( ( ) => res ) ; } return res ; } ) ; }
Write a single value to cache and db

@param  {String} key
@param  {Object} value
@param  {Boolean} testCacheEnabled used for tests
@return {Promise}
Write a single value to cache and db