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
This commit is contained in:
alopexc0de 2014-08-09 19:35:09 -04:00
parent 169fe0fc23
commit da266cce1a
No known key found for this signature in database
GPG Key ID: 48E847F18074C953
1 changed files with 4 additions and 2 deletions

View File

@ -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";
}