Welcome Guest, Not a member yet? Register   Sign In
memcached Usage Error! is it a true usage?
#1

[eluser]Mohammad Rashidi[/eluser]
hi everybody. i have problem using memcached on my WampServer.

apache module is loaded, php extension is active.

these are my codes:

Quote:$this->load->driver('cache');
$this->cache->memcached->save('var_name', 'var_value', 60);
echo $this->cache->memcached->get('var_name');

and this is the result:

Fatal error: Call to a member function add() on a non-object in system\libraries\Cache\drivers\Cache_memcached.php on line 67

but in another hand, i am using this new code, and all caches are going to '/cache/' folder.

i want to use memcached. is this a correct way?
Code:
$this->load->driver('cache', array('adapter' => 'memcached', 'backup' => 'file'));
        
        $this->cache->memcached->is_supported();

        if ( ! $foo = $this->cache->get('foo'))
        {
                 echo 'Saving to the cache!<br />';
                 $foo = 'foobarbaz!';

                 // Save into the cache for 5 minutes
                 $this->cache->save('foo', $foo, 300);
        }

        echo $foo;

it works fine, but pay attention to this:
Quote:'backup' => 'file'

regards.
#2

[eluser]Mohammad Rashidi[/eluser]
additional:

Code:
if(!$this->cache->memcached->is_supported()){
                echo "no";
            }

the result is
Code:
no
#3

[eluser]toopay[/eluser]
I never success configure memcached in Windows Environment. Its very "Linux" for Windows :-S
Please share your set up process, including the compiling process, by write a tutorial, if you success to do that.
#4

[eluser]n0xie[/eluser]
First test if Memcached is working:

Code:
function stats()
{
    $cache = new Memcached();
    $cache->addServer('localhost', 11211);
    var_dump($cache->getStats());
}

Then try this:

Code:
function index()
    {
        $this->load->driver('cache', array('adapter' => 'memcached', 'backup' => 'file'));

        $foo = $this->cache->get('testkey');

        if ( ! $foo )
        {
             echo 'Saving to the cache!<br />';
             $foo = 'test value';

             // Save into the cache for 5 minutes
             $this->cache->save('testkey', $foo, 300);
        }
        else
        {
            var_dump($foo);
        }
    }




Theme © iAndrew 2016 - Forum software by © MyBB