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
-
qdb\QdbExpirableEntry
-
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
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
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
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
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
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
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
Example
$cluster->blob('alias')->update('content');
|