class Bytes implements Serializable (View source)

\Aerospike\Bytes is a utility for wrapping PHP strings containing potentially harmful bytes such as \0. By wrapping the binary-string, the Aerospike client will serialize the data into an as_bytes rather than an as_string.

This ensures that the string will not get truncated or otherwise lose data. The main difference is that strings in the Aerospike cluster can have a secondary index built over them, and queries executed against the index, while bytes data cannot.

Properties

string $s

The container for the binary-string

Methods

__construct(string $bin_str)

Constructor for \Aerospike\Bytes class.

string|null
serialize()

Returns a serialized representation of the binary-string.

void
unserialize(string $bin_str)

Re-wraps the binary-string when called by unserialize().

string
__toString()

Returns the binary-string held in the \Aerospike\Bytes object.

static string
unwrap(Bytes $bytes_wrap)

Unwraps an \Aerospike\Bytes object, returning the binary-string inside.

Details

__construct(string $bin_str)

Constructor for \Aerospike\Bytes class.

Parameters

string $bin_str

a PHP binary-string such as gzdeflate() produces.

string|null serialize()

Returns a serialized representation of the binary-string.

Called by serialize()

Return Value

string|null

The string representation of the object or null

void unserialize(string $bin_str)

Re-wraps the binary-string when called by unserialize().

Parameters

string $bin_str

a PHP binary-string. Called by unserialize().

Return Value

void

string __toString()

Returns the binary-string held in the \Aerospike\Bytes object.

Return Value

string

static string unwrap(Bytes $bytes_wrap)

Unwraps an \Aerospike\Bytes object, returning the binary-string inside.

Parameters

Bytes $bytes_wrap

Return Value

string