mirror of
https://github.com/janishutz/libreevent.git
synced 2025-11-25 13:24:24 +00:00
add gc for db
This commit is contained in:
@@ -185,5 +185,30 @@ module.exports.deleteJSONDataSimple = ( db, identifier ) => {
|
|||||||
} );
|
} );
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const gc = () => {
|
||||||
|
// this function acts as the database garbage collector. TicketTimeout can be changed from the GUI. TODO: Add
|
||||||
|
this.getData( 'temp' ).then( tempData => {
|
||||||
|
let data = tempData;
|
||||||
|
console.info( 'Garbage Collecting' );
|
||||||
|
for ( let item in data ) {
|
||||||
|
if ( new Date( data[ item ][ 'timestamp' ] ).getTime() + ( parseInt( settings.ticketTimeout ) * 1000 ) > new Date().getTime() ) {
|
||||||
|
delete data[ item ];
|
||||||
|
console.debug( 'Garbage collected a session' );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} );
|
||||||
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
Here, GC-Duty is scheduled to run every so often (defined in settings.config.json file, no GUI setting available.
|
||||||
|
If you are a developer and are thinking about adding a GUI setting for this, please consider that this is a
|
||||||
|
advanced setting and many people might not understand what it changes. The config file is mentioned in the
|
||||||
|
"advanced settings" section of the admin panel documentation where all the available settings in the config file
|
||||||
|
are explained in some detail.)
|
||||||
|
*/
|
||||||
|
setInterval( () => {
|
||||||
|
gc();
|
||||||
|
}, parseInt( settings.gcInterval ) );
|
||||||
|
|
||||||
// TODO: Build garbage collector for DB (parse DB every so often (get from settings)
|
// TODO: Build garbage collector for DB (parse DB every so often (get from settings)
|
||||||
// and delete all items where timestamp is older than a certain amount of time (get from settings))
|
// and delete all items where timestamp is older than a certain amount of time (get from settings))
|
||||||
@@ -1 +1,15 @@
|
|||||||
{"init":true,"twoFA":"enforce","setupKey":"hello world","twoFAMode":"enhanced","db":"json","payments":"stripe","name":"libreevent","yourDomain":"http://localhost:8080","mailSender":"libreevent <info@libreevent.janishutz.com>","maxTickets":10,"currency":"CHF"}
|
{
|
||||||
|
"init":true,
|
||||||
|
"twoFA":"enforce",
|
||||||
|
"setupKey":"hello world",
|
||||||
|
"twoFAMode":"enhanced",
|
||||||
|
"db":"json",
|
||||||
|
"payments":"stripe",
|
||||||
|
"name":"libreevent",
|
||||||
|
"yourDomain":"http://localhost:8080",
|
||||||
|
"mailSender":"libreevent <info@libreevent.janishutz.com>",
|
||||||
|
"maxTickets":10,
|
||||||
|
"currency":"CHF",
|
||||||
|
"gcInterval": "600",
|
||||||
|
"ticketTimeout": "900"
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user