Route, Post and CMemCache Hints Required!

Hi all!

This is my first Topic ( I started using yii last week )

Sorry for make 3 questions in only one Topic but i think it will be easy for you.

  1. ROUTE

Hou can i change from :


www.foo.com/?r=site/test

To


www.foo.com/site/test

  1. POST

Is there a way to make a http ‘post’ to an action?

I’m requesting via POST to


www.foo.com/?r=site/test 

and get an error.

  1. MEMCACHE

I’m using memcache, i have all configurated and i am using with php like this:


        $memcache = new Memcache;

        $memcache->connect('localhost', 11211) or die ("Could not connect");

        $CardsCubsObj = $memcache->get('cardinals_cubs');

but i want to use it via Yii, I’ve configurated main.php properly. How can I invoque “CMemCache”?

I want to do something like:


$cache = new CMemCache // with all configurated servers

$cache->set(....)

Thank in advance.

Eduardo Leiva

route: http://www.yiiframework.com/wiki/53/using-search-engine-and-user-friendly-urls

post: yes you can POST to an action, what is the error? maybe actionTest is not set on SiteController? What is the error?

memcache: http://www.yiiframework.com/doc/api/1.1/CMemCache Then you can use your cache: http://www.yiiframework.com/doc/guide/1.1/en/caching.data

Cheers

route: perfect!

post: Always return the default page configurated in config.php.

( i’m using SOAPUi to test )

memcache: I am already using memcache (is working with actual code), but when i try:




$value=Yii::app()->cache->get("foo");

get:

my config file:




'components'=>array(

    	'cache'=>array(

    		'class'=>'CMemCache',

			'useMemcached'=>true,

       	 	'servers'=>array(

        		array(

                    'host'=>'xxx:xxx',

                    'port'=>11211,

                    'weight'=>60,

            	),

          	),

		)

thanks!

Hi,

It seems that when you set its useMemcached= true, Yii will return an instance of MemCached ( http://www.yiiframework.com/doc/api/1.1/CMemCache#getMemCache-detail )




public function getMemCache()

{

    if($this->_cache!==null)

        return $this->_cache;

    else

        return $this->_cache=$this->useMemcached ? new Memcached : new Memcache;

}



That means, that you need to include the file where Memcached is in order to create an instance at any place in the code. The __autoload is failing to include the file… this is the actual error.

About the other problem, have you tried including index.php in your request? www.foo.com/index.php?r=site/test