Quasardb API for PHP
Introduction Installation Compilation Configuration API Reference

Namespaces

  • qdb

Classes

  • QdbAliasAlreadyExistsException
  • QdbAliasNotFoundException
  • QdbBatch
  • QdbBatchResult
  • QdbBlob
  • QdbCluster
  • QdbConnectionException
  • QdbContainerEmptyException
  • QdbDeque
  • QdbEntry
  • QdbEntryCollection
  • QdbException
  • QdbExpirableEntry
  • QdbIncompatibleTypeException
  • QdbInputException
  • QdbInteger
  • QdbOperationDisabledException
  • QdbOperationException
  • QdbProtocolException
  • QdbSystemException
  • QdbTag
  • QdbTagCollection

Class QdbBlob

A blob in the database.

Blob stands for Binary Large Object, meaning that you can store arbitrary data in this blob.

qdb\QdbEntry
Extended by qdb\QdbExpirableEntry
Extended by qdb\QdbBlob
Namespace: qdb
Example:

You get a QdbBlob instance by calling \QdbCluster::blob. Then you can perform atomic operations on the blob:

$cluster->blob('key 0')->put('value 0');
$cluster->blob('key 1')->put('value 1');
$value2 = $cluster->blob('key 2')->get();

Methods summary
public string
# compareAndSwap( string $new_content, string $comparand, integer $expiry_time )

Atomically compares the blob's content with $comparand and updates it to $new_content if, and only if, they match.

Atomically compares the blob's content with $comparand and updates it to $new_content if, and only if, they match.

Parameters

$new_content
The new content of the blob in case of a match.
$comparand
The content to be compared to.
$expiry_time
The absolute expiration time, in seconds since epoch (0 means "never expires").

Returns

string
The original content of the blob if it didn't match $comparand; null if it matched.

Throws

qdb\QdbAliasNotFoundException
qdb\QdbIncompatibleTypeException

Example

$oldContent = $cluster->blob('alias')->compareAndSwap('newContent', 'comparand');
public string
# get( )

Reads the blob's content.

Reads the blob's content.

Returns

string
The blob's content.

Throws

qdb\QdbAliasNotFoundException
qdb\QdbIncompatibleTypeException

Example

$content = $cluster->blob('alias')->get();
public string
# getAndRemove( )

Atomically gets blob's content and removes it.

Atomically gets blob's content and removes it.

Returns

string
The blob's content.

Throws

qdb\QdbAliasNotFoundException
qdb\QdbIncompatibleTypeException

Example

$content = $cluster->blob('alias')->getAndRemove();
public string
# getAndUpdate( string $content, integer $expiry_time = 0 )

Atomically gets the blob's content and replaces it.

Atomically gets the blob's content and replaces it.

Parameters

$content
The new content of the blob.
$expiry_time
The absolute expiration time, in seconds since epoch (0 means "never expires").

Returns

string
The blob's content.

Throws

qdb\QdbAliasNotFoundException
qdb\QdbIncompatibleTypeException

Example

$oldContent = $cluster->blob('alias')->getAndUpdate('newContent');
public
# put( string $content, integer $expiry_time = 0 )

Sets the blob's content, fails if it already exists.

Sets the blob's content, fails if it already exists.

Parameters

$content
The initial content of the blob.
$expiry_time
The absolute expiration time, in seconds since epoch (0 means "never expires").

Throws

qdb\QdbAliasAlreadyExistsException
qdb\QdbIncompatibleTypeException

Example

$cluster->blob('alias')->put('content');
public boolean
# removeIf( string $comparand,… )

Removes the blob if content matches.

Removes the blob if content matches.

Parameters

$comparand,…
The content to be compared to.

Returns

boolean
true if the blob was actually removed; false if not.

Throws

qdb\QdbAliasNotFoundException
qdb\QdbIncompatibleTypeException

Example

$removed = $cluster->blob('alias')->removeIf('comparand');
public boolean
# update( string $content, integer $expiry_time )

Sets the blob's content, creates the blob if needed.

Sets the blob's content, creates the blob if needed.

Parameters

$content
The new content of the blob.
$expiry_time
The absolute expiration time, in seconds since epoch (0 means "never expires").

Returns

boolean
true if the integer was created; false if it was updated.

Throws

qdb\QdbIncompatibleTypeException

Example

$cluster->blob('alias')->update('content');
Methods inherited from qdb\QdbExpirableEntry
expiresAt(), expiresFromNow(), getExpiryTime()
Methods inherited from qdb\QdbEntry
alias(), attachTag(), attachTags(), detachTag(), getTags(), hasTag(), remove()
Copyright 2009-2018 quasardb SAS Documentation generated by ApiGen