Object

\Riak\Object

category

Basho

author

Riak team (https://github.com/basho/riak-php-client/contributors)

Methods

Construct a new Object.

__construct(\Basho\Riak\Client $client, \Basho\Riak\Bucket $bucket, string $key = NULL) 

Arguments

$client

\Basho\Riak\Client

  • A Client object.

$bucket

\Basho\Riak\Bucket

  • A Bucket object.

$key

string

  • An optional key. If not specified, then key is generated by server when store(...) is called.

Get the bucket of this object.

getBucket() : \Basho\Riak\Bucket

Get the key of this object.

getKey() : string

Response

string

Get the data stored in this object.

getData() : array|string

Will return a associative array, unless the object was constructed with newBinary(...) or getBinary(...), in which case this will return a string.

Response

array|string

Set the data stored in this object.

setData(mixed $data) : Object

This data will be JSON encoded unless the object was constructed with newBinary(...) or getBinary(...).

Arguments

$data

mixed

  • The data to store.

Response

Object

Get the HTTP status from the last operation on this object.

status() : integer

Response

integer

Return true if the object exists, false otherwise.

exists() : boolean

Allows you to detect a get(...) or getBinary(...) operation where the object is missing.

Response

boolean

Get the content type of this object.

getContentType() : string

This is either application/json, or the provided content type if the object was created via newBinary(...).

Response

string

Set the content type of this object.

setContentType(string $content_type) : $this

Arguments

$content_type

string

  • The new content type.

Response

$this

Get last-modified from the object.

getLastModified() : \Basho\Riak\DateTime

Response

\Basho\Riak\DateTime

Adds a secondary index to the object

addIndex(string $indexName, string $indexType = null, $explicitValue = null) : $this

This will create the index if it does not exist, or will append an additional value if the index already exists and does not contain the provided value.

Arguments

$indexName

string

$indexType

string

  • Must be one of 'int' or 'bin' - the only two index types supported by Riak

$explicitValue

Response

$this

Sets a given index to a specific value or set of values

setIndex(string $indexName, string $indexType = null, array|string|int $values) : $this

Arguments

$indexName

string

$indexType

string

  • must be 'bin' or 'int'

$values

array|string|int

Response

$this

Gets the current values for the identified index

getIndex(string $indexName, string $indexType = null) 

Note, the NULL value has special meaning - when the object is ->store()d, this value will be replaced with the current value the value of the field matching $indexName from the object's data

Arguments

$indexName

string

$indexType

string

Removes a specific value from a given index

removeIndex(string $indexName, string $indexType = null, $explicitValue = null) : $this

Arguments

$indexName

string

$indexType

string

  • must be 'bin' or 'int'

$explicitValue

Response

$this

Bulk index removal

removeAllIndexes($indexName = null, $indexType = null) : $this

If $indexName and $indexType are provided, all values for the identified index are removed. If just $indexName is provided, all values for all types of the identified index are removed If neither is provided, all indexes are removed from the object

Note that this function will NOT affect auto indexes

Arguments

$indexName

$indexType

Response

$this

Adds an automatic secondary index to the object

addAutoIndex(string $fieldName, string $indexType = null) : $this

The value of an automatic secondary index is determined at time of ->store() by looking for an $fieldName key in the object's data.

Arguments

$fieldName

string

$indexType

string

Must be one of 'int' or 'bin'

Response

$this

Returns whether the object has a given auto index

hasAutoIndex(string $fieldName, string $indexType = null) : boolean

Arguments

$fieldName

string

$indexType

string

  • must be one of 'int' or 'bin'

Response

boolean

Removes a given auto index from the object

removeAutoIndex(string $fieldName, string $indexType = null) : $this

Arguments

$fieldName

string

$indexType

string

Response

$this

Removes all auto indexes

removeAllAutoIndexes(string $fieldName = null, string $indexType = null) : $this

If $fieldName is not provided, all auto indexes on the object are stripped, otherwise just indexes on the given field are stripped. If $indexType is not provided, all types of index for the given field are stripped, otherwise just a given type is stripped.

Arguments

$fieldName

string

$indexType

string

Response

$this

Gets a given metadata value

getMeta(string $metaName) : string|null

Returns null if no metadata value with the given name exists

Arguments

$metaName

string

Response

string|null

Sets a given metadata value

setMeta(string $metaName, string $value) : $this

Overwrites an existing value with the same name if it exists.

Arguments

$metaName

string

$value

string

Response

$this

Removes a given metadata value

removeMeta(string $metaName) : $this

Arguments

$metaName

string

Response

$this

Gets all metadata values

getAllMeta() : \Basho\Riak\array<string>=string

Response

\Basho\Riak\array=string

Strips all metadata values

removeAllMeta() : \Basho\Riak\$this;

Response

\Basho\Riak\$this;

Store the object in Riak

store(integer $w = NULL, integer $dw = NULL) : $this

When this operation completes, the object could contain new metadata and possibly new data if Riak contains a newer version of the object according to the object's vector clock.

Arguments

$w

integer

  • W-value, wait for this many partitions to respond before returning to client.

$dw

integer

  • DW-value, wait for this many partitions to confirm the write before returning to client.

Response

$this

Reload the object from Riak

reload(integer $r = NULL) : $this

When this operation completes, the object could contain new metadata and a new value, if the object was updated in Riak since it was last retrieved.

Arguments

$r

integer

  • R-Value, wait for this many partitions to respond before returning to client.

Response

$this

Delete this object from Riak

delete(integer $dw = NULL) : $this

Arguments

$dw

integer

  • DW-value. Wait until this many partitions have deleted the object before responding.

Response

$this

Reset this object.

clear() : $this

Response

$this

Get the vclock of this object.

vclock() : string

Response

string

Return true if this object has siblings.

hasSiblings() : boolean

Response

boolean

Get the number of siblings that this object contains.

getSiblingCount() : integer

Response

integer

Retrieve a sibling by sibling number.

getSibling(integer $i, integer $r = NULL) : \Basho\Riak\Object.

Arguments

$i

integer

  • Sibling number.

$r

integer

  • R-Value. Wait until this many partitions have responded before returning to client.

Response

\Basho\Riak\Object.

Retrieve an array of siblings.

getSiblings(integer $r = NULL) : array

Arguments

$r

integer

  • R-Value. Wait until this many partitions have responded before returning to client.

Response

array

of Object

Start assembling a Map/Reduce operation.

add($params) : \Basho\Riak\MapReduce
see

Arguments

$params

Response

\Basho\Riak\MapReduce

Start assembling a Map/Reduce operation.

map($params) : \Basho\Riak\MapReduce
see

Arguments

$params

Response

\Basho\Riak\MapReduce

Start assembling a Map/Reduce operation.

reduce($params) : \Basho\Riak\MapReduce
see

Arguments

$params

Response

\Basho\Riak\MapReduce

Properties

Meta data store

meta
var

Meta data store

see

Array of indexes

indexes
var

Array of indexes

see

Array of automatic indexes

autoIndexes
var

Array of automatic indexes

see