Sets the flushable cache to use for this record-set

Using a flushable cache allows clearing the cache when the records
are modified or deleted.

@param SwatDBCacheNsFlushable $cache The flushable cache to use for
this dataobject.
432528
public function setFlushableCache(SwatDBCacheNsFlushable $cache)
    {
        foreach ($this->objects as $object) {
            if ($object instanceof SwatDBFlushable) {
                $object->setFlushableCache($cache);
            }
        }
    }
241270
public function useCache($caching = null)
    {
        if (is_null($caching)) {
            return ($this->useCache && $this->getCache());
        }

        $this->useCache = (bool) $caching;

        return $this;
    }
1341759
public function setObject(ICacheable $cacheable)
    {
        if (!$this->isDisabled()) {
            $path = $this->resolvePath($cacheable->getCacheKey(), true);
            file_put_contents($path, $cacheable->getCacheValue());
        }
    }
631803
public function setCache(CacheProvider $cache, $cacheNamespace, $cacheLifetime)
    {
        $this->cache = $cache;
        $this->cache->setNamespace($cacheNamespace);
        $this->cacheLifetime = $cacheLifetime;
    }
1251714
public function setCaching($caching) {
        if(is_object($caching)) {
            $this->cacheObj = $caching;
            $this->cacheEnabled = true;
        }
        return $this;
    }
15255
public synchronized void setCache(RemoteListCache cache) {
		if (cache != null && (this.cache == null || !this.cache.isComplete())) {
			this.cache = cache;
		}
	}
1114625
public function setCacheName($cache)
    {
        if ($this->sql) {
            if ($this->validateToken($cache)) {
                $this->cache = $cache;
                return true;
            } else {
                throw new SimpleCache_Exception("`$cache` is not a valid field name");
            }
        }
        return false;
    }
355083
public function setCache(AuthAbstract $cache)
  {
    $this->config->setCacheClass(get_class($cache));
    $this->cache = $cache;
  }
268878
public function evaluateDependency($cache): void
    {
        if ($this->reusable) {
            $hash = $this->generateReusableHash();
            if (!array_key_exists($hash, self::$_reusableData)) {
                self::$_reusableData[$hash] = $this->generateDependencyData($cache);
            }
            $this->data = self::$_reusableData[$hash];
        } else {
            $this->data = $this->generateDependencyData($cache);
        }
    }
792694
public function isChanged($cache): bool
    {
        if ($this->reusable) {
            $hash = $this->generateReusableHash();
            if (!array_key_exists($hash, self::$_reusableData)) {
                self::$_reusableData[$hash] = $this->generateDependencyData($cache);
            }
            $data = self::$_reusableData[$hash];
        } else {
            $data = $this->generateDependencyData($cache);
        }

        return $data !== $this->data;
    }
86708
public function setCache($cache) : self
    {
        if (is_string($cache)) {
            $this->cache = CacheFactory::make($cache);
        } elseif ($cache instanceof Cacheable) {
            $this->cache = $cache;
        }

        $prefix = 'tus:' . strtolower((new \ReflectionClass(static::class))->getShortName()) . ':';

        $this->cache->setPrefix($prefix);

        return $this;
    }
336308
public static function clear_static_caches() {
        global $DB;
        // Do not use get/set config here because the caches cannot be relied on.
        $record = $DB->get_record('config', array('name'=>'scheduledtaskreset'));
        if ($record) {
            $record->value = time();
            $DB->update_record('config', $record);
        } else {
            $record = new \stdClass();
            $record->name = 'scheduledtaskreset';
            $record->value = time();
            $DB->insert_record('config', $record);
        }
    }
1150082
public function setCache($cache)
    {
        $this->cache = $cache;
        if ($this->isBool($cache) && $cache === false) {
            $this->cache = $cache;
        } else {
            if (is_object($cache)) {
                if ($this->isInstanceOf($cache, CacheStorage::class)) {
                    $this->cache = $cache;
                } else {
                    throw new RouterException('$cache must either be a boolean or instance of ' . CacheStorage::class . '.');
                }
            } else {
                $this->cache = $this->cache($cache);
            }
        }
    }
1362165
public function setCache() {
        if (!file_exists($this->_fileName)) {
            file_put_contents($this->_fileName, $this->_compress(serialize($this->_content)));
        }

        $timeAgo = time() - filemtime($this->_fileName);

        if ($timeAgo > $this->_time) {
            file_put_contents($this->_fileName, $this->_compress(serialize($this->_content)));
        }
    }
1200790
public function set(CacheableInterface $item)
    {
        $this->provider->save($item->getHashKey(), $item->getDataForCache(), $item->getTtl());
    }
1137683
public function clear($cache = null)
    {
        if ($cache === null) {
            $cache = $this->cache_name;
        }
        $cache = self::encodeCache($cache);
        $url = "projects/{$this->project_id}/caches/$cache/clear";
        $params = array();
        $this->setJsonHeaders();
        return self::json_decode($this->apiCall(self::POST, $url, $params));
    }
586038
public static function clear($key)
    {
        $that = new static($key);

        if ($that->isCached()) {

            $deletionSuccess = unlink($that->filePath());
            
            if(!$deletionSuccess) {
                throw new CacheException(sprintf("Could not delete file '%s'", $this->filePath()));
            }
        }
    }