/**
* @param $key string
* @param $value mixed
+ * @param $exptime int
* @return bool success
*/
public function replace( $key, $value, $exptime = 0 ) {
* @param $key String: Key to increase
* @param $value Integer: Value to add to $key (Default 1)
* @return null if lock is not possible else $key value increased by $value
- * @return success
+ * @return bool success
*/
public function incr( $key, $value = 1 ) {
if ( !$this->lock( $key ) ) {
return $exptime;
}
}
+
+ /**
+ * Convert an optionally absolute expiry time to a relative time. If an
+ * absolute time is specified which is in the past, use a short expiry time.
+ *
+ * @param $exptime integer
+ * @return integer
+ */
+ protected function convertToRelative( $exptime ) {
+ if ( $exptime >= 86400 * 3650 /* 10 years */ ) {
+ $exptime -= time();
+ if ( $exptime <= 0 ) {
+ $exptime = 1;
+ }
+ return $exptime;
+ } else {
+ return $exptime;
+ }
+ }
}