let Data = {};
setTimeout(DeleteData_, 30000);
function DeleteData_() {
    let DateNow = Date.now();
    for (key in Data) {
        if (Data[key] != undefined) {
            if (Data[key]["过期时间"] < DateNow) {
                delete Data[key];
            }
        }
    }
}
exports.InsertData = function (name, values, NoTime) {
    let DateNow = Date.now();
    NoTime=NoTime*1000;
    if (Data[name] == undefined) {
        Data[name] = {
            "name": values,
            "过期时间": DateNow+NoTime
        };
    } else {
        if(Data[name]["过期时间"]!=undefined){
            if (Data[name]["过期时间"] < DateNow) {
                Data[name] = {
                    "name": values,
                    "过期时间": DateNow+NoTime
                };
            }
        }else{
            Data[name] = {
                "name": values,
                "过期时间": DateNow+NoTime
            };
        }
    }
}
exports.UpdateData = function (name, values, NoTime) {
    Data[name] = {
        "name": values,
        "过期时间": NoTime
    };
}
exports.DeleteData = function (name) {
    if (Data[name] != undefined) {
        delete Data[name];
    }
}
exports.SelectData = function (name) {
    if (Data[name] == undefined) {
        return undefined;
    } else {
        let DateNow = Date.now();
        if(Data[name]["过期时间"]!=undefined){
            if (Data[name]["过期时间"] < DateNow) {
                return undefined;
            }else{
                return Data[name]["name"]
            }
        }else{
            return undefined;
        }
    }
}