在 codeigniter 中使用 memcache
我需要有一个可以与我的 codeigniter 一起用作内存缓存的库。我需要做的是根据用户角色从数据库中提取菜单,然后将菜单存储在缓存中。这个想法是向具有相同角色的另一个用户显示确切的菜单(不调用数据库)。我有一个单独的菜单视图(标题),并将其包含在我的每个页面(视图)上。这里需要注意的是每次控制器在请求新页面(视图)时执行。
我刚刚使用了一个库 https://github.com/tomschlick/memcached-library ,但没有在这种情况下为我工作。当我调用新页面时,标头视图会因未定义内存缓存的获取函数而引发错误(因为我通过内存缓存获取标头中的数据)。
有没有可靠的库或方法来完成任务?
谢谢
I need to have library that can be used as memcache with my codeigniter. what I need to do is to extract menus from DB on user's role basis and then store the menu in cache. The idea is to show the exact menu to another user if it has the same role(without calling DB). I have a separate view for menus(Header) and includes it on each of my page(view). Here a thing to note is every time a controller is executed when requesting to a new page(view).
I just used a library https://github.com/tomschlick/memcached-library which did not work for me in this scenario. As I call the new page the header view throws an error for not defined get function for memcache (as I am getting data in header through memcache).
Is there any solid library or way to accomplish the task?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
CodeIgniter2 有缓存库,支持 Memcache https://www.codeigniter。 com/user_guide/libraries/caching.html#memcached-caching
使用类似的东西:
CI 论坛
CodeIgniter2 has caching library, which supports Memcache https://www.codeigniter.com/user_guide/libraries/caching.html#memcached-caching
Use something lilke that:
Sample memcache.php from the CI forum
有一个论坛帖子,其中概述了正确的方法:
http://codeigniter.com/forums/viewthread/ 180005/
There is a forum post with the correct method outlined here:
http://codeigniter.com/forums/viewthread/180005/