public function loadFromCache()
    {
        if ($this->items !== null || !$this->cache instanceof Cache) {
            return;
        }

        $data = $this->cache->get($this->cacheKey);
        if (is_array($data) && isset($data[0], $data[1])) {
            list ($this->items, $this->rules) = $data;
            return;
        }

        $query = (new Query)->from($this->itemCollection);
        $this->items = [];
        foreach ($query->all($this->db) as $row) {
            $this->items[$row['name']] = $this->populateItem($row);
        }

        $query = (new Query)->from($this->ruleCollection);
        $this->rules = [];
        foreach ($query->all($this->db) as $row) {
            $this->rules[$row['name']] = unserialize($row['data']);
        }

        $this->cache->set($this->cacheKey, [$this->items, $this->rules]);
    }
public function loadFromCache()
    {
        if ($this->items !== null || !$this->cache instanceof Cache) {
            return;
        }

        $data = $this->cache->get($this->cacheKey);
        if (is_array($data) && isset($data[0], $data[1])) {
            list ($this->items, $this->rules) = $data;
            return;
        }

        $query = (new Query)->from($this->itemCollection);
        $this->items = [];
        foreach ($query->all($this->db) as $row) {
            $this->items[$row['name']] = $this->populateItem($row);
        }

        $query = (new Query)->from($this->ruleCollection);
        $this->rules = [];
        foreach ($query->all($this->db) as $row) {
            $this->rules[$row['name']] = unserialize($row['data']);
        }

        $this->cache->set($this->cacheKey, [$this->items, $this->rules]);
    }
public function loadFromCache ( ) { if ( $ this -> items !== null || ! $ this -> cache instanceof Cache ) { return ; } $ data = $ this -> cache -> get ( $ this -> cacheKey ) ; if ( is_array ( $ data ) && isset ( $ data [ 0 ] , $ data [ 1 ] ) ) { list ( $ this -> items , $ this -> rules ) = $ data ; return ; } $ query = ( new Query ) -> from ( $ this -> itemCollection ) ; $ this -> items = [ ] ; foreach ( $ query -> all ( $ this -> db ) as $ row ) { $ this -> items [ $ row [ 'name' ] ] = $ this -> populateItem ( $ row ) ; } $ query = ( new Query ) -> from ( $ this -> ruleCollection ) ; $ this -> rules = [ ] ; foreach ( $ query -> all ( $ this -> db ) as $ row ) { $ this -> rules [ $ row [ 'name' ] ] = unserialize ( $ row [ 'data' ] ) ; } $ this -> cache -> set ( $ this -> cacheKey , [ $ this -> items , $ this -> rules ] ) ; }
Loads data from cache
Loads data from cache