Search code examples
symfony1memcached

Configure Symfony for use with Memcached


I have 2 Symfony applications (1 using 1.2.x, another using 1.4.x and both using Propel) that need to share some specific session information. Although I have no experience with memcached, my sense--after some reading--is that it may be able to serve as an external (FAST) repository that each app could read and write to. Unfortunately, I can't find much information about how to use it with Symfony in any capacity, much less in the quasi-cache, quasi-messaging server I'm envisioning.

My questions, I suppose, are:

  • Am I mistaken in believing that memcached be used in this manner and access by multiple systems?
  • How can I configure Symfony to access a memcached repository?

Thanks.


Solution

  • This explains one approach fairly well (you don't need the view cache stuff, just the second half about making a singleton available and configuring it):

    http://dev.esl.eu/blog/2009/06/05/memcached-as-singleton-in-symfony/

    edit: now 404, but still available here

    You can then use:

    sfMemcache::getInstance()->set()
    

    and

    sfMemcache::getInstance()->get()
    

    (same as the methods here as sfMemcache subclasses Memcache).

    As long as both apps point to the same memcache, you should be able to share data between them like this.