From da266cce1a5ce177543453509132d50b61da47bd Mon Sep 17 00:00:00 2001 From: alopexc0de Date: Sat, 9 Aug 2014 19:35:09 -0400 Subject: [PATCH] Change link expire time to future (in secs) expire() and setex() store as a countdown from now and doesn't persist it between server reboots and repopulation. This is fixed by setting the keys to expire at a time in the future --- Website/Include/PHP/functions.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Website/Include/PHP/functions.php b/Website/Include/PHP/functions.php index adfea5b..7c93c4d 100644 --- a/Website/Include/PHP/functions.php +++ b/Website/Include/PHP/functions.php @@ -34,6 +34,7 @@ } } while (1); + $now = time(NULL); $xTime = 3136320000; // About 100 years, give or take // Delete the links in 24 hours, 1 week, 1 month respectevly @@ -44,9 +45,10 @@ $redis->rpush("links:$short", $link); $redis->rpush("links:$short", $title); $redis->rpush("links:$short", date("d/m/Y", strtotime($str))); - $redis->expire("links:$short", $xTime); + $redis->expireAt("links:$short", $now+$xTime); - $redis->setex("tracking:clicks:$link", $xTime, 1); + $redis->set("tracking:clicks:$link", 1); + $redis->expireAt("tracking:clicks:$link", $now+$xTime); return "0$seperator$short$seperator$title"; }