2023-08-25 08:23:53 -07:00
|
|
|
<?php
|
|
|
|
function load_cooldowns() {
|
2023-08-25 11:09:06 -07:00
|
|
|
if (function_exists("apcu_fetch"))
|
2023-08-25 10:57:23 -07:00
|
|
|
return apcu_exists("cooldowns") ? apcu_fetch("cooldowns") : array();
|
|
|
|
return array();
|
2023-08-25 08:23:53 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
function save_cooldowns($cooldowns) {
|
2023-08-25 11:09:06 -07:00
|
|
|
if (function_exists("apcu_store"))
|
2023-08-25 10:57:23 -07:00
|
|
|
apcu_store("cooldowns", $cooldowns);
|
2023-08-25 08:23:53 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
function set_cooldown($instance, $timeout, $cooldowns) {
|
|
|
|
$cooldowns[$instance] = time() + $timeout;
|
|
|
|
save_cooldowns($cooldowns);
|
|
|
|
return $cooldowns;
|
|
|
|
}
|
|
|
|
|
|
|
|
function has_cooldown($instance, $cooldowns) {
|
|
|
|
return ($cooldowns[$instance] ?? 0) > time();
|
|
|
|
}
|
|
|
|
?>
|