public function triggerEvent(string $event): void
    {
        // TODO: use event library and allow attach events to IFile and ICacheStateful.
        // cache triggers
        if ($this->file instanceof ICacheStateful) {
            switch ($event) {
                case self::EVENT_CACHED:
                    $this->file->setCachedAt($this->name, time());
                    break;
                case self::EVENT_EMPTY:
                case self::EVENT_ERROR:
                case self::EVENT_NOT_FOUND:
                    // TODO: split those and save different cases of cache state.
                    $this->file->setCachedAt($this->name, null);
                    break;
            }

            $this->file->saveState();
        }

        // other triggers
    }
public function triggerEvent(string $event): void
    {
        // TODO: use event library and allow attach events to IFile and ICacheStateful.
        // cache triggers
        if ($this->file instanceof ICacheStateful) {
            switch ($event) {
                case self::EVENT_CACHED:
                    $this->file->setCachedAt($this->name, time());
                    break;
                case self::EVENT_EMPTY:
                case self::EVENT_ERROR:
                case self::EVENT_NOT_FOUND:
                    // TODO: split those and save different cases of cache state.
                    $this->file->setCachedAt($this->name, null);
                    break;
            }

            $this->file->saveState();
        }

        // other triggers
    }
public function triggerEvent ( string $ event ) : void { // TODO: use event library and allow attach events to IFile and ICacheStateful. // cache triggers if ( $ this -> file instanceof ICacheStateful ) { switch ( $ event ) { case self :: EVENT_CACHED : $ this -> file -> setCachedAt ( $ this -> name , time ( ) ) ; break ; case self :: EVENT_EMPTY : case self :: EVENT_ERROR : case self :: EVENT_NOT_FOUND : // TODO: split those and save different cases of cache state. $ this -> file -> setCachedAt ( $ this -> name , null ) ; break ; } $ this -> file -> saveState ( ) ; } // other triggers }
Call user function after saving cached file
@param string $event
Call user function after saving cached file