Prado\Caching\TSqliteCache::init PHP Method

init() public method

This method is required by the IModule interface. It checks if the DbFile property is set, and creates a SQLiteDatabase instance for it. The database or the cache table does not exist, they will be created. Expired values are also deleted.
public init ( $config )
    public function init($config)
    {
        if (!function_exists('sqlite_open')) {
            throw new TConfigurationException('sqlitecache_extension_required');
        }
        if ($this->_file === null) {
            $this->_file = $this->getApplication()->getRuntimePath() . '/sqlite.cache';
        }
        $error = '';
        if (($this->_db = new \SQLiteDatabase($this->_file, 0666, $error)) === false) {
            throw new TConfigurationException('sqlitecache_connection_failed', $error);
        }
        if (@$this->_db->query('DELETE FROM ' . self::CACHE_TABLE . ' WHERE expire<>0 AND expire<' . time()) === false) {
            if ($this->_db->query('CREATE TABLE ' . self::CACHE_TABLE . ' (key CHAR(128) PRIMARY KEY, value BLOB, expire INT)') === false) {
                throw new TConfigurationException('sqlitecache_table_creation_failed', sqlite_error_string(sqlite_last_error()));
            }
        }
        $this->_initialized = true;
        parent::init($config);
    }