Change KeyValue time
This commit is contained in:
@@ -203,13 +203,17 @@ const moduleFuncs = {
|
||||
const { bot } = context;
|
||||
const { KeyValue } = bot;
|
||||
bot.gameOfLife = {
|
||||
games: new KeyValue(15 * 60 * 1000),
|
||||
games: new KeyValue(),
|
||||
createGame(size, id) {
|
||||
const game = new this.GameOfLife(size);
|
||||
this.games.store(id, {
|
||||
game,
|
||||
endTime: new Date().getTime() + 15 * 60 * 1000,
|
||||
});
|
||||
this.games.store(
|
||||
id,
|
||||
{
|
||||
game,
|
||||
endTime: new Date().getTime() + 15 * 60 * 1000,
|
||||
},
|
||||
15 * 60 * 1000
|
||||
);
|
||||
return game;
|
||||
},
|
||||
|
||||
|
||||
@@ -1,14 +1,13 @@
|
||||
function main(context) {
|
||||
const { bot } = context;
|
||||
bot.KeyValue = class {
|
||||
constructor(time) {
|
||||
this.time = time;
|
||||
constructor() {
|
||||
this.map = new Map();
|
||||
}
|
||||
|
||||
store(key, value) {
|
||||
store(key, value, time) {
|
||||
this.map.set(key, value);
|
||||
setTimeout(() => this.map.delete(key), this.time);
|
||||
setTimeout(() => this.map.delete(key), time);
|
||||
}
|
||||
|
||||
get(key) {
|
||||
|
||||
Reference in New Issue
Block a user