/** * Load the table dependencies for dynamic cache breaking. */ private static function load_dependants() { self::$dependants = []; if (class_exists('\\classes\\db')) { if (!db::table_exists('_cache_dependants')) { db::create_table('_cache_dependants', ['key' => 'INT', 'hash' => 'BINARY(16)']); } $res = db::query('SELECT * FROM _cache_dependants'); while ($row = db::fetch($res, false)) { self::$dependants[$row['key']] = $row['hash']; } } }
public static function break_cache($table) { if (in_array($table, static::$ignore_tables)) { return; } $res = db::select('_compiler_keys')->add_field_to_retrieve('file')->filter('`dependants` LIKE "%' . $table . '%"')->execute(); while ($row = db::fetch($res)) { switch (static::$mode) { case static::MODE_FILE: static::break_file($row->file); break; case static::MODE_REDIS: //$this->break_redis($row->file); throw new \Exception('Page caching method is not implemented - Redis'); break; case static::MODE_MEMCACHED: static::break_memcached($row->file); break; } } db::delete('_compiler_keys')->filter('`dependants` LIKE "%' . $table . '%"')->execute(); }