implementing disk cache

Swift Mailer is a fantastic library for sending email with php. Discuss this library or ask any questions about it here.

Moderators: Chris Corbyn, General Moderators

Post Reply
ctfb
Forum Newbie
Posts: 2
Joined: Tue Mar 06, 2007 8:17 pm

implementing disk cache

Post 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?
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Re: implementing disk cache

Post by Chris Corbyn »

You don't need to edit anything, just override it :)

Code: Select all

Swift_Preferences::getInstance()->setTempDir('/path/to/dir');
ctfb
Forum Newbie
Posts: 2
Joined: Tue Mar 06, 2007 8:17 pm

Re: implementing disk cache

Post by ctfb »

thanks. love swiftmailer. you rock.
Post Reply