'use strict';

var cache = {};

var expiryTime = 1000 * 60 * 60 * 24;

function getKey (city, targetLang, sourceLang) {
  return [city, targetLang, sourceLang].join(';');
}

exports.get = function getItem (city, targetLang, sourceLang) {
  return cache[getKey(city, targetLang, sourceLang)];
};

exports.set = function setItem (city, targetLang, sourceLang, translation) {
  var key = getKey(city, targetLang, sourceLang);

  cache[key] = translation;

  setTimeout(function removeItem () {
    delete cache[key];
  }, expiryTime);
};

@@ -237,21 +237,18 @@
 %7B%0A  
-return cache%5B
+var key = 
 getK
@@ -279,17 +279,173 @@
 rceLang)
-%5D
+;%0A  var item = cache%5Bkey%5D;%0A%0A  if(!item)%7B%0A    return;%0A  %7D%0A%0A  if((Date.now() - item.time) %3E= expiryTime)%7B%0A    delete cache%5Bkey%5D;%0A  %7D%0A%0A  return item.translation
 ;%0A%7D;%0A%0Aex
@@ -584,16 +584,22 @@
 e%5Bkey%5D =
+ %7B%0A   
  transla
@@ -606,88 +606,47 @@
 tion
-;%0A%0A  setTimeout(function removeItem () %7B%0A    delete cache%5Bkey%5D;%0A  %7D, expiryTime)
+: translation,%0A    time: Date.now()%0A  %7D
 ;%0A%7D;

Update cache to delete on retrieve instead of using timeouts