public function cas($token, $key, $value, $expiration = 0, $flags = self::FLAG_DEFAULT, $bytes = null)
    {
        /**
         * cas <key> <flags> <exptime> <bytes> <cas unique> [noreply]\r\n
         * <value>\r\n
         */

        // Run through our serializer
        $serialized = $this->serializeValue($value);

        $value = $serialized['value'];
        $flags = $serialized['flags'];
        $bytes = $serialized['bytes'];

        // Calculate bytes if not precalculated
        $bytes = ($bytes !== null) ? $bytes : strlen($value);

        // Build packet to send ...
        $data = self::COMMAND_CAS . self::COMMAND_SEPARATOR   .
            $key                  . self::COMMAND_SEPARATOR   .
            $flags                . self::COMMAND_SEPARATOR   .
            $expiration           . self::COMMAND_SEPARATOR   .
            $bytes                . self::COMMAND_SEPARATOR   .
            $token                . self::COMMAND_TERMINATOR  .
            $value                . self::COMMAND_TERMINATOR;

        return $this->send(self::COMMAND_CAS, $data);
    }
public function cas($token, $key, $value, $expiration = 0, $flags = self::FLAG_DEFAULT, $bytes = null)
    {
        /**
         * cas <key> <flags> <exptime> <bytes> <cas unique> [noreply]\r\n
         * <value>\r\n
         */

        // Run through our serializer
        $serialized = $this->serializeValue($value);

        $value = $serialized['value'];
        $flags = $serialized['flags'];
        $bytes = $serialized['bytes'];

        // Calculate bytes if not precalculated
        $bytes = ($bytes !== null) ? $bytes : strlen($value);

        // Build packet to send ...
        $data = self::COMMAND_CAS . self::COMMAND_SEPARATOR   .
            $key                  . self::COMMAND_SEPARATOR   .
            $flags                . self::COMMAND_SEPARATOR   .
            $expiration           . self::COMMAND_SEPARATOR   .
            $bytes                . self::COMMAND_SEPARATOR   .
            $token                . self::COMMAND_TERMINATOR  .
            $value                . self::COMMAND_TERMINATOR;

        return $this->send(self::COMMAND_CAS, $data);
    }
public function cas ( $ token , $ key , $ value , $ expiration = 0 , $ flags = self :: FLAG_DEFAULT , $ bytes = null ) { /**
         * cas <key> <flags> <exptime> <bytes> <cas unique> [noreply]\r\n
         * <value>\r\n
         */ // Run through our serializer $ serialized = $ this -> serializeValue ( $ value ) ; $ value = $ serialized [ 'value' ] ; $ flags = $ serialized [ 'flags' ] ; $ bytes = $ serialized [ 'bytes' ] ; // Calculate bytes if not precalculated $ bytes = ( $ bytes !== null ) ? $ bytes : strlen ( $ value ) ; // Build packet to send ... $ data = self :: COMMAND_CAS . self :: COMMAND_SEPARATOR . $ key . self :: COMMAND_SEPARATOR . $ flags . self :: COMMAND_SEPARATOR . $ expiration . self :: COMMAND_SEPARATOR . $ bytes . self :: COMMAND_SEPARATOR . $ token . self :: COMMAND_TERMINATOR . $ value . self :: COMMAND_TERMINATOR ; return $ this -> send ( self :: COMMAND_CAS , $ data ) ; }
Tries to set a key value pair by using a cas token.
If value was updated between the moment when retrieving the cas-value and the
moment now calling this method the cas has changed and update will fail.

@param string   $token      a unique 64-bit value of an existing entry.
Clients should use the value returned from the
"gets" command when issuing "cas" updates.
@param string   $key        The key to set
@param mixed    $value      The value to set
@param int      $expiration The expire time as seconds from now (must be < 30 days) OR a timestamp
@param int      $flags      The flags to set
@param int|null $bytes      The length in bytes

@author Benjamin Carl <opensource@clickalicious.de>
@return mixed The response for command cas
@access public
Tries to set a key value pair by using a cas token . If value was updated between the moment when retrieving the cas - value and the moment now calling this method the cas has changed and update will fail .