ここの情報は古いです。ご理解頂いた上でお取り扱いください。

Changeset 3182


Ignore:
Timestamp:
Jun 4, 2007, 8:04:11 PM (12 years ago)
Author:
ebihara
Message:

memcachedに保存されたファンクションキャッシュを正常に参照できるようにした

Location:
OpenPNE/branches/ebihara/prj_memcached/webapp/lib
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • OpenPNE/branches/ebihara/prj_memcached/webapp/lib/Cache/Container/memcached.php

    r3181 r3182  
    11<?php
     2/**
     3 * @copyright 2005-2007 OpenPNE Project
     4 * @license   http://www.php.net/license/3_01.txt PHP License 3.01
     5 */
    26
    37require_once 'Cache/Container.php';
    48
    5 /**
    6 * PEAR/DB Cache Container.
    7 *
    8 * WARNING: Other systems might or might not support certain datatypes of
    9 * the tables shown. As far as I know there's no large binary
    10 * type in SQL-92 or SQL-99. Postgres seems to lack any
    11 * BLOB or TEXT type, for MS-SQL you could use IMAGE, don't know
    12 * about other databases. Please add sugestions for other databases to
    13 * the inline docs.
    14 *
    15 * The field 'changed' has no meaning for the Cache itself. It's just there
    16 * because it's a good idea to have an automatically updated timestamp
    17 * field for debugging in all of your tables.
    18 *
    19 * For _MySQL_ you need this DB table:
    20 *
    21 * CREATE TABLE cache (
    22 *   id          CHAR(32) NOT null DEFAULT '',
    23 *   cachegroup  VARCHAR(127) NOT null DEFAULT '',
    24 *   cachedata   BLOB NOT null DEFAULT '',
    25 *   userdata    VARCHAR(255) NOT null DEFAULT '',
    26 *   expires     INT(9) NOT null DEFAULT 0,
    27 *
    28 *   changed     TIMESTAMP(14) NOT null,
    29 *
    30 *   INDEX (expires),
    31 *   PRIMARY KEY (id, cachegroup)
    32 * )
    33 *
    34 * @author   Sebastian Bergmann <sb@sebastian-bergmann.de>
    35 * @version  $Id: db.php,v 1.8 2005/01/26 09:42:30 dufuz Exp $
    36 * @package  Cache
    37 */
    389class Cache_Container_memcached extends Cache_Container
    3910{
    40 
     11    /**
     12     * Memcache Object
     13     *
     14     * @var object Memcache
     15     */
    4116    var $memcached;
    4217
     
    5025
    5126    function fetch($id, $group)
    52     {var_dump($id . '-fetch');
     27    {
    5328        $cachedata = $this->memcached->get($id);
    54         var_dump($cachedata);
     29
    5530        $unserialized = unserialize($this->decode($cachedata));
    5631        $expire = 0;  // ロード時のexpireは判定には用いない
    5732        $userdata = '';
    58         $data = array($expire, $unserializeds, $userdata);
     33        $data = array($expire, $unserialized, $userdata);
    5934
    6035        return $data;
     
    6237
    6338    function save($id, $data, $expires, $group, $userdata)
    64     {var_dump($id . '-save'); var_dump($expires);
     39    {
    6540        $this->expires = $expires;
    6641        $serialized = $this->encode(serialize($data));
     
    6944
    7045    function remove($id, $group)
    71     {var_dump($id . '-remove');
     46    {
    7247        return $this->memcached->delete($id);
    73     }
    74 
    75     function flush($group = '')
    76     {var_dump($id . '-flush');
    77         $this->flushPreload();
    78         return null;
    7948    }
    8049
     
    8453    }
    8554
    86 
    8755    function isExpired($id, $group, $max_age)
    8856    {
    8957        // memcachedはコール時に指定した時間で削除されるので、キャッシュ生存期間判定は不要
    9058        // よって、キャッシュが存在しているかどうかで生存期間内かどうかを判定
    91         return $this->idExists($id, $group);
    92     }
    93 
    94     function garbageCollection($maxlifetime)
    95     {
    96         $this->flushPreload();
    97         return true;
     59        $is_cache_exists = $this->idExists($id, $group);
     60       
     61        if ($is_cache_exists) {
     62            return false;
     63        } else {
     64            return true;
     65        }
    9866    }
    9967
  • OpenPNE/branches/ebihara/prj_memcached/webapp/lib/util/cache.php

    r3181 r3182  
    6969{
    7070    if (OPENPNE_USE_FUNCTION_CACHE) {
    71         var_dump('rec');
    7271        array_unshift($funcarg, $function);
    7372        $cache =& get_cache_lite_function();
Note: See TracChangeset for help on using the changeset viewer.