/**
 * Created by pc on 2015/9/17.
 */
var config = require('../conf/config.js').config();
var Memcached = require('memcached');
var memcached = new Memcached(config.r.memcached.server, config.r.memcached.options);
module.exports= {
    get: function (key) {
        return function (callback) {
            memcached.get("finance_" + key, callback);
        }
    },
    set: function (key, value, maxAge) {
        maxAge = maxAge || 60;
        memcached.set("finance_" + key, value, maxAge, function (err) {
            if (err) console.log("mc setting error");
        });
    },
    remove:function(key){
        memcached.set("finance_" + key, value, -1, function (err) {//删除缓存
            if (err) console.log("mc setting error");
        });
    },
    end:function(){
        memcached.end();
    }
};

