/*!
 * memories: A simple in-memory caching module for Node.js
 *
 * Copyright(c) 2011 Sven Lito. <me@svenlito.com>
 * MIT LICENCE
 *
 */

var util = require('util');

var cache = {},
    now = function() { return (new Date()).getTime(); };

var memories = {

  put: function(key, value, validFor) {
    var expire = validFor + now();

    cache[key] = {
      value: value,
      expire: expire
    };

    if (!isNaN(expire)) {
      setTimeout(function() { this.del(key); }, expire);
    }
  },

  get: function(key) {
    var data = cache[key];

    if (typeof(data) !== "undefined") {
      if (isNaN(data.expire) || data.expire >= now()) {
        return data.value;
      }
    } else {
      return null;
    }
  },

  del: function(key) {
    delete cache[key];
  },

  size: function() {
    var size = 0, key;

    for (key in cache) {
      if (cache.hasOwnProperty(key)) {
        if (memories.get(key) !== null) {
          size++;
        }
      }
    }
    return size;
  }
};

module.exports = memories;

@@ -305,36 +305,177 @@
 var 
-expire = validFor + now();%0A%0A
+args = Array.prototype.slice.call(arguments),%0A        expire = validFor + now();%0A%0A    if (!args %7C%7C args.length === 0) %7B%0A      return 'missing arguments';%0A    %7D else %7B%0A  
     
@@ -495,16 +495,18 @@
 %7B%0A      
+  
 value: v
@@ -511,16 +511,18 @@
  value,%0A
+  
       ex
@@ -538,20 +538,24 @@
 ire%0A    
+  
 %7D;%0A%0A
+  
     if (
@@ -578,16 +578,18 @@
 %7B%0A      
+ 
+ 
 setTimeo
@@ -631,16 +631,24 @@
 xpire);%0A
+      %7D%0A
     %7D%0A  

make sure we pass params to put method