สอนพัฒนา phpBB : ตัวอย่างการใช้ cache ใน phpbb

phpBB Extension Developing Knowledge สำหรับ แชร์ความรู้การพัฒนา extension ของ phpBB 3.1

Moderator: phpbb, mindphp, ผู้ดูแลกระดาน

ตอบกลับโพส
thatsawan
phpBBThailand Sr. Member
phpBBThailand Sr. Member
โพสต์: 57
ลงทะเบียนเมื่อ: 31 มี.ค. 2014, 10:10

สอนพัฒนา phpBB : ตัวอย่างการใช้ cache ใน phpbb

โพสต์ โดย thatsawan »

โค้ด: เลือกทั้งหมด

if (($cache_data = $this->cache->get('_cache_data_')) === false) {
                        // .. Code .. 
                       // .. $rowset ข้อมูลที่จะใส่ แคช
                            $this->cache->put('_cache_data_' , $rowset, 86400);
                            $this->cache->put('_cache_topic_id_' , $topic_tag_id, 86400);
                        }
                    } else {

                        $rowset = $cache_data;
                        $topic_tag_id = $this->cache->get('_cache_topic_id_');
                    }
เช็คว่ามี cache นี้หรือไม

โค้ด: เลือกทั้งหมด

$cache_data = $this->cache->get('_cache_data_')) === false
เก็บค่าใส่ cache

โค้ด: เลือกทั้งหมด

  $this->cache->put('_cache_data_' , $rowset, 86400);
นำ cache มาใช้งาน

โค้ด: เลือกทั้งหมด

   
   //  $this->cache->get();
    $topic_tag_id = $this->cache->get('_cache_topic_id_');
ตอบกลับโพส

ย้อนกลับไปยัง

ผู้ใช้งานขณะนี้

กำลังดูบอร์ดนี้: 21 และ บุคคลทั่วไป 0 ท่าน