Dear Mathieu ,

Thanks for your valuable answer. I managed to install memcached and
its extension in ubuntu and caching is working fine. My following code
is working fine.

[syntax=php]<?php
error_reporting(-1);
ini_set('display_errors', true);
    $memcache = new Memcache();
    //$memcache->connect("10.1.11.33",11211) or die ("Could not
connect");
        $memcache->addServer("10.1.11.33",11211, 33);
        echo "version = " . print_r($memcache->getVersion());

        if ( ! extension_loaded('memcache')) {
            throw new Doctrine_Cache_Exception('In order to use
Memcache driver, the memcache extension must be loaded.');
    }
?>[/syntax]

And from symfony I used resultcaching. It is also working. I verified
by modifying the content in the database and the modified content is
not loading in the result. But after the life span the changed content
is loading.

Here is the code snippet which I used to load the cache driver in the
symfony framwork.

 [syntax=php]   public function configureDoctrine(Doctrine_Manager
$manager) {
        $servers = array(
            'host' => '10.1.11.33',
            'port' => 11211,
            'persistent' => true
        );
        $cacheDriver = new Doctrine_Cache_Memcache(array(
            'servers' => $servers,
            'compression' => false
            )
        );
        //enable Doctrine cache
        $manager = Doctrine_Manager::getInstance();
        $manager->setAttribute(Doctrine::ATTR_RESULT_CACHE,
$cacheDriver);
        $manager->setAttribute(Doctrine::ATTR_RESULT_CACHE_LIFESPAN,
900);
    }[/syntax]

But I have one more issue. When I tried to clear the cache it is
giving me the an error [quote]In order to use Memcache driver, the
memcache extension must be loaded.[/quote]

But in the sample code this error is not returning.

Do u have any solutions for this?

regards
Shihab


On Dec 30 2010, 7:24 pm, Wizermil <mathieu.gar...@gmail.com> wrote:
> Hi Shihab,
>
> I think you can use memcached or APC cahce system, it's available in
> doctrine:http://www.doctrine-project.org/documentation/manual/1_1/en/caching
>
> To implement it in yoursymfonyproject you just have to let doctrine
> knows that it can use a cache system
> 1. In ProjectConfiguration.class.php for Memcached
>     public function configureDoctrine(Doctrine_Manager $manager) {
>
>         $servers = array(
>             'host' => 'localhost',
>             'port' => 11211,
>             'persistent' => true
>         );
>
>         $cacheDriver = new Doctrine_Cache_Memcache(array(
>             'servers' => $servers,
>             'compression' => false
>             )
>         );
>
>         $manager->setAttribute(Doctrine::ATTR_RESULT_CACHE,
> $cacheDriver);
>     }
> 2. Change a little bit your DQL requests to let doctrine knows that it
> must check the cache before sending the request to mysql
> You have to use the method useResultCache (http://www.doctrine-
> project.org/api/orm/1.2/doctrine/
> doctrine_query_abstract.html#useResultCache())
>
> I hope that it will help you.
>
> Cheers,
>
> Mathieu
>
> On 27 déc, 13:11, Shihab KB <shiha...@gmail.com> wrote:
>
> > Hi,
>
> > We have created a restful web service usingsymfony(symfony1.4 and
> > doctrine ORM) for a content management system. Clients from various
> > location of the world access the data of the content management system
> > thru the restful apis. Each time of api call the data base query is
> > required. We are thinking about implementing some caching mechanism
> > likememcache.
>
> > Can somebody implementedmemcachefor restful web services? Please
> > advise me. Can u give me steps to implementmemcache?
>
> > regards
> > Shihab

-- 
If you want to report a vulnerability issue on symfony, please send it to 
security at symfony-project.com

You received this message because you are subscribed to the Google
Groups "symfony users" group.
To post to this group, send email to symfony-users@googlegroups.com
To unsubscribe from this group, send email to
symfony-users+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/symfony-users?hl=en

Reply via email to