Reputation: 355
How to use phpactiverecord memcached? anyone can help me?
$database = array(
'connection' => 'local',
'local' => 'mysql://username:password@localhost/database?charset=utf8',
'server' => 'mysql://username:password@localhost/database?charset=utf8',
'memcache' => 'memcache://localhost:11211'
);
ActiveRecord\Config::initialize(function($config) use ($database) {
$config->set_connections($database);
$config->set_default_connection($database['connection']);
$config->set_cache($database['memcache'], array('namespace' => 'My', 'expire' => 120));
});
As default i get admin data from admin model like this
use My\Admin;
use ActiveRecord\Model;
class Admin extends Model {
static $table_name = 'web_admin';
}
print_r(Admin::all());
So, how to set admin data into memcached and how to get that data?
Upvotes: 0
Views: 541
Reputation: 91
Their documentation doesn't explain anything about how to use caching but their github link says that you can do it just by setting cache variable to TRUE. So you will need to set.
static $cache = TRUE;
in the models for which you want to cache the queries.
Upvotes: 1