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

请教,Cache::setter中your_custom_set_cache怎么使用 #149

Closed
stonegithubs opened this issue Nov 7, 2015 · 3 comments
Closed

请教,Cache::setter中your_custom_set_cache怎么使用 #149

stonegithubs opened this issue Nov 7, 2015 · 3 comments

Comments

@stonegithubs
Copy link

自定义缓存
use Overtrue\Wechat\Cache;

// 写入
Cache::setter(function($key, $value, $lifetime){
return your_custom_set_cache($key, $value, $lifetime);
});

// 读取
Cache::getter(function($key){
return your_custom_get_cache($key);
});
请教下,自定义的方法有什么作用?
可以直接这样写吗?
Cache::setter(function(‘abc’, $value, 3600){
return true;
});
谢谢~~~~

@overtrue
Copy link
Collaborator

overtrue commented Nov 7, 2015

自定义的方法有什么作用?

就是自定义缓存写入与读取的方式。

Cache::setter(function(‘abc’, $value, 3600){
return true;
});

你的意思是你不想缓存?

@stonegithubs
Copy link
Author

谢谢,我是这样缓存的
use Overtrue\Wechat\Cache;
$prefix = ‘wx’;
$Cache = new Cache($prefix);
$Cache->set('access_token', $access_token);
$Cache->set('refresh_token', $refresh_token);
$access_token = $Cache->get('access_token');
$refresh_token = $Cache->get('refresh_token');
缓存数据正常,读取也正常
另外请教下setter和getter以及里面的自定义函数有什么用处,要自定义函数,能实现什么更强大的功能?
Cache::setter(function($key, $value, $lifetime){
return your_custom_set_cache($key, $value, $lifetime);
});
Cache::getter(function($key){
return your_custom_get_cache($key);
});

@overtrue
Copy link
Collaborator

overtrue commented Nov 9, 2015

your_custom_set_cache 是不存在的,只是 举例的一个名称,意思是这里你用自己的方式去 缓存

@overtrue overtrue closed this as completed Nov 9, 2015
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