public static function set($key, $data, $ttl = self::TTL_NO_EXPIRY, $tags = [])
    {
        if (!$cache = self::getInstance()) {
            return false;
        }

        $key = self::prepare($key);
        try {
            $item = $cache->getItem($key);
            $item->set($data);

            if (self::TTL_NO_EXPIRY !== $ttl) {
                $item->expiresAfter($ttl);
            }

            if (!empty($tags)) {
                $item->setTags($tags);
            }

            return $cache->save($item);
        } catch (InvalidArgumentException $e) {
            // something going wrong
            Logger::error($e->getMessage());
        }

        return false;
    }
public static function set($key, $data, $ttl = self::TTL_NO_EXPIRY, $tags = [])
    {
        if (!$cache = self::getInstance()) {
            return false;
        }

        $key = self::prepare($key);
        try {
            $item = $cache->getItem($key);
            $item->set($data);

            if (self::TTL_NO_EXPIRY !== $ttl) {
                $item->expiresAfter($ttl);
            }

            if (!empty($tags)) {
                $item->setTags($tags);
            }

            return $cache->save($item);
        } catch (InvalidArgumentException $e) {
            // something going wrong
            Logger::error($e->getMessage());
        }

        return false;
    }
public static function set ( $ key , $ data , $ ttl = self :: TTL_NO_EXPIRY , $ tags = [ ] ) { if ( ! $ cache = self :: getInstance ( ) ) { return false ; } $ key = self :: prepare ( $ key ) ; try { $ item = $ cache -> getItem ( $ key ) ; $ item -> set ( $ data ) ; if ( self :: TTL_NO_EXPIRY !== $ ttl ) { $ item -> expiresAfter ( $ ttl ) ; } if ( ! empty ( $ tags ) ) { $ item -> setTags ( $ tags ) ; } return $ cache -> save ( $ item ) ; } catch ( InvalidArgumentException $ e ) { // something going wrong Logger :: error ( $ e -> getMessage ( ) ) ; } return false ; }
Set value of cache item

@param  string   $key
@param  mixed    $data
@param  int      $ttl
@param  string[] $tags

@return bool
Set value of cache item