Skip to content

Commit

Permalink
Merge pull request #135 from dongnan/final
Browse files Browse the repository at this point in the history
Replaced all @Date("U") to time()
  • Loading branch information
khoaofgod committed Sep 12, 2015
2 parents beb1f94 + a690326 commit 3ef6a1f
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 12 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -226,3 +226,8 @@ pip-log.txt
.idea/scopes/scope_settings.xml
.idea/vcs.xml
.idea/workspace.xml

#################
## NetBeans
#################
nbproject/
10 changes: 5 additions & 5 deletions phpfastcache/3.0.0/abstract.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ public function set($keyword, $value = "", $time = 0, $option = array() ) {
}
$object = array(
"value" => $value,
"write_time" => @date("U"),
"write_time" => time(),
"expired_in" => $time,
"expired_time" => @date("U") + (Int)$time,
"expired_time" => time() + (Int)$time,
);

return $this->driver_set($keyword,$object,$time,$option);
Expand Down Expand Up @@ -114,7 +114,7 @@ function increment($keyword, $step = 1 , $option = array()) {
return false;
} else {
$value = (Int)$object['value'] + (Int)$step;
$time = $object['expired_time'] - @date("U");
$time = $object['expired_time'] - time();
$this->set($keyword,$value, $time, $option);
return true;
}
Expand All @@ -126,7 +126,7 @@ function decrement($keyword, $step = 1 , $option = array()) {
return false;
} else {
$value = (Int)$object['value'] - (Int)$step;
$time = $object['expired_time'] - @date("U");
$time = $object['expired_time'] - time();
$this->set($keyword,$value, $time, $option);
return true;
}
Expand All @@ -140,7 +140,7 @@ function touch($keyword, $time = 300, $option = array()) {
return false;
} else {
$value = $object['value'];
$time = $object['expired_time'] - @date("U") + $time;
$time = $object['expired_time'] - time() + $time;
$this->set($keyword, $value,$time, $option);
return true;
}
Expand Down
2 changes: 1 addition & 1 deletion phpfastcache/3.0.0/drivers/files.php
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ function driver_isExisting($keyword) {

function isExpired($object) {

if(isset($object['expired_time']) && @date("U") >= $object['expired_time']) {
if(isset($object['expired_time']) && time() >= $object['expired_time']) {
return true;
} else {
return false;
Expand Down
12 changes: 6 additions & 6 deletions phpfastcache/3.0.0/drivers/sqlite.php
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ function driver_set($keyword, $value = "", $time = 300, $option = array() ) {
$stm->execute(array(
":keyword" => $keyword,
":object" => $this->encode($value),
":exp" => @date("U") + (Int)$time,
":exp" => time() + (Int)$time,
));

return true;
Expand All @@ -212,7 +212,7 @@ function driver_set($keyword, $value = "", $time = 300, $option = array() ) {
$stm->execute(array(
":keyword" => $keyword,
":object" => $this->encode($value),
":exp" => @date("U") + (Int)$time,
":exp" => time() + (Int)$time,
));
} catch (PDOException $e) {
return false;
Expand Down Expand Up @@ -268,7 +268,7 @@ function driver_get($keyword, $option = array()) {
}

function isExpired($row) {
if(isset($row['exp']) && @date("U") >= $row['exp']) {
if(isset($row['exp']) && time() >= $row['exp']) {
return true;
}

Expand All @@ -280,7 +280,7 @@ function deleteRow($row) {
$stm = $this->db($row['keyword'])->prepare("DELETE FROM `caching` WHERE (`id`=:id) OR (`exp` <= :U) ");
$stm->execute(array(
":id" => $row['id'],
":U" => @date("U"),
":U" => time(),
));
} catch (PDOException $e) {
return false;
Expand All @@ -292,7 +292,7 @@ function driver_delete($keyword, $option = array()) {
$stm = $this->db($keyword)->prepare("DELETE FROM `caching` WHERE (`keyword`=:keyword) OR (`exp` <= :U)");
$stm->execute(array(
":keyword" => $keyword,
":U" => @date("U"),
":U" => time(),
));
} catch (PDOException $e) {
return false;
Expand Down Expand Up @@ -324,7 +324,7 @@ function driver_stats($option = array()) {

$stm = $PDO->prepare("DELETE FROM `caching` WHERE `exp` <= :U");
$stm->execute(array(
":U" => @date("U"),
":U" => time(),
));

$PDO->exec("VACUUM;");
Expand Down

0 comments on commit 3ef6a1f

Please sign in to comment.