Jump to:

23550 Posts in 19336 Topics by 2890 members

General Questions

SilverStripe Forums » General Questions » Cache

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Page: 1
Go to End
Author Topic: 1561 Views
  • Tonyair
    Avatar
    Community Member
    81 Posts

    Cache Link to this post

    Hi, guys. I just wounder if I could use caching in dev mode.
    Cuz i want to debug profile, memory and etc with cache system on.

    So here's my example:
    _config.php:

    SS_Cache::add_backend('primary_memcached', 'Memcached',
       array(
          'host' => 'localhost', 'port' => 11211,
          'persistent' => true, 'weight' => 1,
          'timeout' => 5, 'retry_interval' => 15,
          'status' => true, 'failure_callback' => ''
       )
    );
    SS_Cache::pick_backend('primary_memcached', 'any', 10);
    SS_Cache::pick_backend('default', 'aggregate', 20);
    SS_Cache::set_cache_lifetime('primary_memcached', 2000, 1);
    SS_Cache::set_cache_lifetime('default', 2000, 2);

    heavy template function:

    $cache = SS_Cache::factory('primary_memcached');      
    if (!$records = unserialize($cache->load('222555'))) {
       echo "AAAA! "
       $records = DataObject::get($obj, $filter, $sort, $join, $limit);
       $cache->save(serialize($records),'222555');
    }
    return $records;

    When i see AAA! it means cache isn't works when i don't it's ok.
    So I had set cache lifetime, but still it works in live mode only.

    UPD: FIXED, just forgot about the other config file

  • shizny8
    Avatar
    Community Member
    3 Posts

    Re: Cache Link to this post

    Hi, I'm having issues with setting up memcached in silverstripe. What other config file did you update and do you know how to get silverstripe to use memcached for the template cacheing... I'm still getting a lot of files written to silverstripe-cache directory?

    my _config has

    SS_Cache::add_backend('primary_memcached', 'Memcached', array('host' => 'localhost', 'port' => 11211, 'persistent' => true, 'weight' => 1, 'timeout' => 5, 'retry_interval' => 15, 'status' => true, 'failure_callback' => '' ) );

    SS_Cache::pick_backend('primary_memcached', 'any', 10);
    SS_Cache::pick_backend('default', 'aggregate', 20);

    1561 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.