Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

General Questions /

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

Cache


Reply


2 Posts   1593 Views

Avatar
Tonyair

Community Member, 81 Posts

22 April 2011 at 11:06am

Edited: 22/04/2011 11:31am

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

Avatar
shizny8

Community Member, 3 Posts

6 March 2013 at 3:05pm

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);