public function cache($key, \Closure $value, $ttl = null)
    {
        // $value可以是callable或是值
        if (static::$cacheManager) {
            if (!static::$cacheManager->getAssistant()) {
                static::$cacheManager = static::$cacheManager->withTags(get_class($this));
            }

            return static::$cacheManager->remember(
                $key,
                $value,
                $ttl ?: $this->ttl
            );
        } else {
            return $value();
        }
    }
public function cache($key, \Closure $value, $ttl = null)
    {
        // $value可以是callable或是值
        if (static::$cacheManager) {
            if (!static::$cacheManager->getAssistant()) {
                static::$cacheManager = static::$cacheManager->withTags(get_class($this));
            }

            return static::$cacheManager->remember(
                $key,
                $value,
                $ttl ?: $this->ttl
            );
        } else {
            return $value();
        }
    }
public function cache ( $ key , \ Closure $ value , $ ttl = null ) { // $value可以是callable或是值 if ( static :: $ cacheManager ) { if ( ! static :: $ cacheManager -> getAssistant ( ) ) { static :: $ cacheManager = static :: $ cacheManager -> withTags ( get_class ( $ this ) ) ; } return static :: $ cacheManager -> remember ( $ key , $ value , $ ttl ? : $ this -> ttl ) ; } else { return $ value ( ) ; } }
Cache a value in the model's cache collection.

@param $key
@param Closure $value
@param $ttl

@return mixed
Cache a value in the model s cache collection .