/** * บันทึก cache เมื่อบันทึกแล้วจะปิดการใช้งาน cache อัตโนมัติ * จะใช้คำสั่งนี้เมื่อมีการเรียกใช้แคชด้วยคำสั่ง cacheOn(false) เท่านั้น * query ครั้งต่อไปถ้าจะใช้ cache ต้อง เปิดการใช้งาน cache ก่อนทุกครั้ง * * @param array $datas ข้อมูลที่จะบันทึก * @return boolean สำเร็จคืนค่า true ไม่สำเร็จคืนค่า false */ public function save($datas) { $this->action = 0; if ($this->item instanceof Item) { $this->item->set($datas); return $this->db_cache->save($this->item); } return false; }
/** * อ่านแคชหลายรายการ * * @param array $keys * @return array */ public function getItems(array $keys = array()) { $resuts = array(); foreach ($keys as $key) { $file = $this->fetchStreamUri($key); if ($this->isExpired($file)) { $item = new Item($key); $resuts[$key] = $item->set(unserialize(preg_replace('/^<\\?php\\sexit\\?>/', '', file_get_contents($file), 1))); } } return $resuts; }
/** * อ่านแคชหลายรายการ * * @param array $keys * @return array */ public function getItems(array $keys = array()) { $resuts = array(); $success = false; $values = apc_fetch($keys, $success); if ($success && is_array($values)) { foreach ($values as $key => $value) { $item = new Item($key); $resuts[$key] = $item->set($value); } } return $resuts; }
/** * บันทึก cache เมื่อบันทึกแล้วจะปิดการใช้งาน cache อัตโนมัติ * จะใช้คำสั่งนี้เมื่อมีการเรียกใช้แคชด้วยคำสั่ง cacheOn(false) เท่านั้น * query ครั้งต่อไปถ้าจะใช้ cache ต้อง เปิดการใช้งาน cache ก่อนทุกครั้ง * * @param Item $item * @param array $datas ข้อมูลที่จะบันทึก * @return boolean สำเร็จคืนค่า true ไม่สำเร็จคืนค่า false */ public function save(Item $item, $datas) { $this->action = 0; $item->set($datas); return $this->db_cache->save($item); }