Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

生成AccessToken时,似乎没有调用自定义缓存的delete方法 #693

Closed
Insua opened this issue May 11, 2017 · 7 comments
Closed

Comments

@Insua
Copy link

Insua commented May 11, 2017

我用的环境

PHP 版本:5.6
overtrue/wechat 版本:3.1

问题及现象

我重写了一个mysql的DoctrineCache缓存,调整了过期时间后,读取缓存时,会重新生成很多token,而原有的token并没有被删除

@overtrue
Copy link
Collaborator

删除是需要你自己实现的啊,不然过期时间有啥用?

@Insua
Copy link
Author

Insua commented May 11, 2017

<?php
use Doctrine\Common\Cache\Cache as CacheInterface;
class MyCacheDriver implements CacheInterface
{
..............
.............
 public function delete($id)
    {
        // 删除并返回 bool 值
    }   

这里的delete方法我已经重写了啊,业务逻辑就写了一条SQL 语句

DELETE FROM cache WHERE id=$id

delete方法还需要写其他东西嘛?

@overtrue
Copy link
Collaborator

过期清除并不是 Doctrine Cache 这个组件去做的事情,redis, mc 这些都是自带过期清除功能的, mysql 没有过期时间的概念,所以需要定时执行脚本去删除过期的,明白么?

@Insua
Copy link
Author

Insua commented May 11, 2017

好的,谢谢
那我在fetch方法里判断过期后,直接调用

$this->delete($id)

@overtrue
Copy link
Collaborator

可以啊,只要符合该机制就行了

@Insua
Copy link
Author

Insua commented May 11, 2017

谢谢安正超大神,我正在等待你设计的laravel文化衫到货,我close comment了

@Insua Insua closed this as completed May 11, 2017
@overtrue
Copy link
Collaborator

❤️ 加油!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants