Page 1 of 1

implementing disk cache

Posted: Fri Apr 03, 2009 7:16 am
by ctfb
In v3 I used to set the cache to disk with

Code: Select all

Swift_CacheFactory::setClassName("Swift_Cache_Disk");
    Swift_Cache_Disk::setSavePath("../includes/swiftmailer/tmp");
In v4 in the preferences I found this

Code: Select all

if (function_exists('sys_get_temp_dir') && is_writable(sys_get_temp_dir()))
{
  Swift_Preferences::getInstance()
    -> setTempDir(sys_get_temp_dir())
    -> setCacheType('disk');
}
but I don't understand how to give it a path to a writable dir. I can't seem to find the sys_get_temp_dir() function. Looking at the Swift_Preferences class it would seem all I have to do is put a path string in setTempDir(). Is that right or should I change the value in the dependency_maps for the cache? Also, how do I know that it is using the cache and not writing to an array? Can I assume with the disk cache that adding 3 or 4 megs of attachments while using the decorator plugin shouldn't be a problem?

Re: implementing disk cache

Posted: Fri Apr 03, 2009 8:48 am
by Chris Corbyn
You don't need to edit anything, just override it :)

Code: Select all

Swift_Preferences::getInstance()->setTempDir('/path/to/dir');

Re: implementing disk cache

Posted: Fri Apr 03, 2009 9:56 am
by ctfb
thanks. love swiftmailer. you rock.