取系统缓存管理器.

@param string $type 缓存类型

@return Cache
963361
public static function getCache($type = '') {
        static $caches = [];

        if (!$type) {
            $loader = new ConfigurationLoader();
            $cfg    = $loader->loadConfig('cache');
            $type   = $cfg->get('default', CACHE_TYPE_REDIS);
        }
        if (!isset($caches[ $type ])) {
            if (!isset($cfg)) {
                $loader = new ConfigurationLoader();
                $cfg    = $loader->loadConfig('cache');
            }
            if (!$cfg->getb('enabled')) {
                return new Cache();
            }
            $cache = apply_filter('get_' . $type . '_cache', null, $cfg);
            if (!$cache instanceof Cache) {
                $cache = new Cache ();
            }
            $caches[ $type ] = $cache;
        }

        return $caches[ $type ];
    }
1098994
public function compile($type = 'select')
    {

        // Raw Type
        if ($this->rawQuery) {
            // Bind value
            $this->bindValue();

            return $this->queryString;
        }

        $this->queryString = '';

        if ($type == 'select') {
            $this->compileSelect();
            $this->compileFrom();
            $this->compileJoin();
            $this->compileWhere();
            $this->compileGroupBy();
            $this->compileOrderBy();
            $this->compileOffset();
        } elseif ($type == 'count') {
            $this->compileCount();
            $this->compileFrom();
            $this->compileJoin();
            $this->compileWhere();
            $this->compileGroupBy();
        } elseif ($type == 'insert') {
            $this->compileInsert();
        } elseif ($type == 'update') {
            $this->compileUpdate();
            $this->compileJoin();
            $this->compileWhere();
        } elseif ($type == 'delete') {
            $this->compileDelete();
            $this->compileFrom();
            $this->compileJoin();
            $this->compileWhere();
            $this->compileGroupBy();
        }

        // Bind value
        $this->bindValue();

        return $this->queryString;
    }
1078679
public static function getInstance($type, $init)
    {
        if (!self::$cachingInstance) {
            self::$cachingInstance = new MemcachedCache($type, $init);
        }

        return self::$cachingInstance;
    }
1069672
public function unregisterCacheResource($type)
    {
        if (isset($this->smarty->registered_cache_resources[$type])) {
            unset($this->smarty->registered_cache_resources[$type]);
        }
    }
1306006
protected static function _cache($type, $key, $value = false)
    {
        $key = '_' . $key;
        $type = '_' . $type;
        if ($value !== false) {
            self::$_cache[$type][$key] = $value;
            return $value;
        }
        if (!isset(self::$_cache[$type][$key])) {
            return false;
        }
        return self::$_cache[$type][$key];
    }
1162056
public static function getInstance($type, $init)
    {

        if (!self::$cachingInstance) {
            self::$cachingInstance = new SessionCache($type, $init);
        }

        return self::$cachingInstance;
    }
1113961
public function withType(string $type): self
    {
        $metadata = clone $this;
        $metadata->type = $type;

        return $metadata;
    }
726924
public function type($type = null)
    {
        if ($type !== null) {
            $this->type = $type;
            return $this;
        }
        return $this->type;
    }
361868
public function cacheSize( $type = self::PERSISTED )
    {
        switch( $type ) {
            case self::PERSISTED:
                return count( $this->instancesPersisted );
            case self::UNPERSISTED:
                return count( $this->instancesUnpersisted );
            case self::ALL:
                return $this->cacheSize( self::PERSISTED ) + $this->cacheSize( self::UNPERSISTED );
        }
        throw new \InvalidArgumentException("Bad source `{$source}` passed to " . __FUNCTION__);
    }
44470
private static function getFromCache($type)
    {
        if (!isset(self::$cache[$type])) {
            return;
        }

        $candidate = self::$cache[$type];
        if (isset($candidate['condition'])) {
            if (!self::evaluateCondition($candidate['condition'])) {
                return;
            }
        }

        return $candidate['class'];
    }
240495
private function getFromMemory($type)
    {
        if (isset($this->loaded[$type])) {
            return $this->loaded[$type];
        }
        return null;
    }
302293
public function cacheInvalidate( $type = self::ALL )
    {
        switch( $type ) {
            case self::PERSISTED:
                $return = count( $this->instancesPersisted );
                $this->instancesPersisted = array();
                return $return;
            case self::UNPERSISTED:
                $return = count( $this->instancesUnpersisted );
                $this->instancesUnpersisted = array();
                return $return;
            case self::ALL:
                $return = count( $this->instancesPersisted ) + count( $this->instancesUnpersisted );
                $this->instancesPersisted = array();
                $this->instancesUnpersisted = array();
                return $return;
        }
        throw new \InvalidArgumentException("Bad source `{$source}` passed to " . __FUNCTION__);
    }
1153977
private function getFromCache($type)
    {
        if (false === $this->hasCache()) {
            return null;
        }
        return $this->cache->loadMetadataFromCache($type);
    }
192023
public function addType($type)
    {
        if (!in_array($type, $this->validTypes())) {
            throw new InvalidArgumentException(
                sprintf('Invalid cache type: "%s"', $type)
            );
        }

        $this->types[$type] = true;
        return $this;
    }
1113775
public static function getInstance($type)
    {
        $classname = self::getClassname($type);

        if (!isset(self::$__instances[$classname])) {
            $instance = new $classname();
            self::$__instances[$classname] = $instance;
        }

        $instance = clone self::$__instances[$classname];

        return $instance;
    }
673207
public function clear($type = null)
    {
        if (is_null($type)) {
            $_SESSION[$this->key] = [];
        } else {
            unset($_SESSION[$this->key][$type]);
        }

        return $this;
    }
201148
private function load($type)
    {
        $index = $this->$type;
        if ($index) {
            return;
        }

        $cache = $this->di->get("cache");
        $key = $cache->createKey(__CLASS__, $type);
        $index = $cache->get($key);

        if (is_null($index) || $this->ignoreCache) {
            $createMethod = "create$type";
            $index = $this->$createMethod();
            $cache->put($key, $index);
        }

        $this->$type = $index;
    }