public static function get_instance() { if (!self::$_instance) { self::$_instance = new self(); } return self::$_instance; }
public function on_changed() { $t = Lib_Keyvalue::readone($this); $t->set('body'); $this->db = 1; $Lib_Memory = Lib_Memory::get_instance(); $Lib_Memory->add($t->get_ckey(), $t, true); }
public static function readall($instance) { $table_name = $instance->get_table(); $key = 'TMJ_Keyvalue_' . $table_name; $Lib_Memory = Lib_Memory::get_instance(); if (!$Lib_Memory->exist($key)) { $db_key = $instance->get_db_key(); $t = new self(); $t->set_db_key($db_key); $t->set_table($table_name); $memcache = $t->get_memcache(); $data = $memcache->get($key); if (!is_array($data)) { $all = $t->fetch_all('', $t->get_pk_name()); $data = array(); foreach ($all as $k => $v) { $data[$k] = $v->body; } $memcache->set($key, $data, 0, 0); } $Lib_Memory->add($key, $data, false); } return $Lib_Memory->find($key); }
protected function __flush() { Lib_Memory::on_end(); }