src/Charcoal/Model/Service/ModelLoader.php
public function load($ident, $useCache = true, $reloadObj = false)
    {
        if (!$useCache) {
            return $this->loadFromSource($ident);
        }

        $cacheKey  = $this->cacheKey($ident);
        $cacheItem = $this->cachePool->getItem($cacheKey);

        if (!$reloadObj) {
            if ($cacheItem->isHit()) {
                $data = $cacheItem->get();
                $obj  = $this->factory->create($this->objType);
                $obj->setData($data);

                return $obj;
            }
        }

        $obj  = $this->loadFromSource($ident);
        $data = ($obj->id() ? $obj->data() : []);
        $cacheItem->set($data);
        $this->cachePool->save($cacheItem);

        return $obj;
    }
public function load($ident, $useCache = true, $reloadObj = false)
    {
        if (!$useCache) {
            return $this->loadFromSource($ident);
        }

        $cacheKey  = $this->cacheKey($ident);
        $cacheItem = $this->cachePool->getItem($cacheKey);

        if (!$reloadObj) {
            if ($cacheItem->isHit()) {
                $data = $cacheItem->get();
                $obj  = $this->factory->create($this->objType);
                $obj->setData($data);

                return $obj;
            }
        }

        $obj  = $this->loadFromSource($ident);
        $data = ($obj->id() ? $obj->data() : []);
        $cacheItem->set($data);
        $this->cachePool->save($cacheItem);

        return $obj;
    }
public function load ( $ ident , $ useCache = true , $ reloadObj = false ) { if ( ! $ useCache ) { return $ this -> loadFromSource ( $ ident ) ; } $ cacheKey = $ this -> cacheKey ( $ ident ) ; $ cacheItem = $ this -> cachePool -> getItem ( $ cacheKey ) ; if ( ! $ reloadObj ) { if ( $ cacheItem -> isHit ( ) ) { $ data = $ cacheItem -> get ( ) ; $ obj = $ this -> factory -> create ( $ this -> objType ) ; $ obj -> setData ( $ data ) ; return $ obj ; } } $ obj = $ this -> loadFromSource ( $ ident ) ; $ data = ( $ obj -> id ( ) ? $ obj -> data ( ) : [ ] ) ; $ cacheItem -> set ( $ data ) ; $ this -> cachePool -> save ( $ cacheItem ) ; return $ obj ; }
Retrieve an object, by its key, from its source or from the cache.

When the cache is enabled, only the object's _data_ is stored. This prevents issues
when unserializing a class that might have dependencies.

@param  string|integer $ident     The object identifier to load.
@param  boolean        $useCache  If FALSE, ignore the cached object. Defaults to TRUE.
@param  boolean        $reloadObj If TRUE, refresh the cached object. Defaults to FALSE.
@return ModelInterface
Retrieve an object by its key from its source or from the cache .