Skip to content
This repository has been archived by the owner on Jan 4, 2020. It is now read-only.

Commit

Permalink
Merge pull request #383 from smdcn/scdev
Browse files Browse the repository at this point in the history
Memcached 驱动过期时间设置问题
  • Loading branch information
liu21st committed Mar 9, 2016
2 parents 1b1ad4e + 8794f96 commit 60cdc4b
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion ThinkPHP/Library/Think/Cache/Driver/Memcached.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ public function set($name, $value, $expire = null)
$expire = $this->options['expire'];
}
$name = $this->options['prefix'] . $name;
if ($this->handler->set($name, $value, time() + $expire)) {
$expire = $expire == 0 ? 0 : time() + $expire;
if ($this->handler->set($name, $value, $expire)) {
if ($this->options['length'] > 0) {
// 记录缓存队列
$this->queue($name);
Expand Down

3 comments on commit 60cdc4b

@hongweipeng
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这有什么区别吗

@oyvfhp
Copy link

@oyvfhp oyvfhp commented on 60cdc4b Mar 11, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

直接用等于0,还不如用is_number,既然是设置缓存,传入0(立即失效)了,还有什么意思。

@hongweipeng
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

同意楼上,不如用is_number

$expire = !is_number( $expire) ? 0 : time() + $expire;

$expire == 0 ? 0 : 并没有什么卵用

Please sign in to comment.