Quasardb API for PHP
Introduction Installation Compilation Configuration API Reference

Classes

  • QdbBatch
  • QdbBatchResult
  • QdbBlob
  • QdbCluster
  • QdbDeque
  • QdbEntry
  • QdbEntryCollection
  • QdbExpirableEntry
  • QdbHashSet
  • QdbInteger
  • QdbTag
  • QdbTagCollection

Exceptions

  • QdbAliasAlreadyExistsException
  • QdbAliasNotFoundException
  • QdbConnectionException
  • QdbContainerEmptyException
  • QdbException
  • QdbIncompatibleTypeException
  • QdbInputException
  • QdbOperationDisabledException
  • QdbOperationException
  • QdbProtocolException
  • QdbSystemException

Class QdbBlob

A blob in the database.

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

QdbEntry
Extended by QdbExpirableEntry
Extended by QdbBlob
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

QdbAliasNotFoundException
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

QdbAliasNotFoundException
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

QdbAliasNotFoundException
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

QdbAliasNotFoundException
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

QdbAliasAlreadyExistsException
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

QdbAliasNotFoundException
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

QdbIncompatibleTypeException

Example

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