Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

How to use cache feature on my own site?

Hi guys,

I want to know how to use cache feature on my own site?

The following is my code that try to use cache to save value into cache and get value from cache,but it looks always initialize a useless Gdn_Dirtycache Object in my code:

Gdn::Cache()->Store('mbqTestVar', serialize(array('v1', 'v2', 'v3')), array( Gdn_Cache::FEATURE_EXPIRY => 120 )); error_log(print_r(unserialize(Gdn::Cache()->Get('mbqTestVar')), true));

So I suppose I missed something or did something wrong in my code.

Anybody can help?

Thanks.

Comments

  • hgtonighthgtonight ∞ · New Moderator

    Caching is not my strong suit, but I believe you need to enable the APC module in PHP and set the cache method in your config. $Configuration['Cache']['Method'] = 'apc';

    I know @shadowdare and @x00 for sure use caching. Perhaps they could share some more information.

    Search first

    Check out the Documentation! We are always looking for new content and pull requests.

    Click on insightful, awesome, and funny reactions to thank community volunteers for their valuable posts.

  • x00x00 MVP
    edited February 2014

    APC is actually not implement by the framework as an cache option. However turning it on can improve performance gernall with php. It has to be configure right to not interfere with config.php, etc

    You could write a wrapper for it though, if you are a competent coder. Extend Gdn_Cache you can follow the other cache systems in /library as a guide.

    You can use memcached. You need to install memcache an the php mecached (not to be confused with php memcache). I'm not goign to cover the installation.

    The file cache isn't worth it. If you are unable to install a memory cache don't both with caching, use a cdn.

    grep is your friend.

  • Hi,

    Thank you for your reply.

    You mean I must implement the cache feature by myself,and the vanilla 2 has not native cache solution to use?

  • R_JR_J Ex-Fanboy Munich Admin

    You can use memcached. You have to install it by yourself and use something like that in your config.php:

        $Configuration['Cache']['Enabled'] = TRUE;
        $Configuration['Cache']['Method'] = 'memcache';
        $Configuration['memcache']['Store'] = 'localhost';
    

    I know the search is broken in the moment but you can use google to search for discussions about that topic: https://www.google.de/#q=site:vanillaforums.org+memcached

  • @wzttest1 said:
    Hi,

    Thank you for your reply.

    You mean I must implement the cache feature by myself,and the vanilla 2 has not native cache solution to use?

    No forums software install caching solutions. It doesn't install your file system does it? (rhetorical) It is made to work with php memecached. It can be made to work with apc.

    It has file cache, but mostly likely it would use up too much resource writing to file to be worth it, unless you have very efficient hardware, and file system.

    One of the myths is cache is an easy meal ticket, but you actually have to have the right resources to run it. it is often trading one resorce for another to get better performance, based on you setup.

    turn apc on will help php performance in general much of the time. It has it own caching on a lower level.However it is memory based, so you would need to have the memory.

    grep is your friend.

Sign In or Register to comment.