Documentation

S3Storage extends AbstractData
in package

AbstractData

Abstract model for data access

Table of Contents

Properties

$_last_cache  : array<string|int, mixed>
cache for the traffic limiter
$_bucket  : string
S3 bucket
$_client  : S3Client
S3 client
$_options  : array<string|int, mixed>
S3 client options
$_prefix  : string
S3 prefix for all PrivateBin data in this bucket

Methods

__construct()  : mixed
instantiates a new S3 data backend.
create()  : bool
Create a paste.
createComment()  : bool
Create a comment in a paste.
delete()  : mixed
Delete a paste and its discussion.
exists()  : bool
Test if a paste exists.
existsComment()  : bool
Test if a comment exists.
getAllPastes()  : array<string|int, mixed>
Returns all paste ids
getValue()  : string
Load a value.
purge()  : mixed
Perform a purge of old pastes, at most the given batchsize is deleted.
purgeValues()  : void
Purge outdated entries.
read()  : array<string|int, mixed>|false
Read a paste.
readComments()  : array<string|int, mixed>
Read all comments of paste.
setValue()  : bool
For S3, the value will also be stored in the metadata for the namespaces traffic_limiter and purge_limiter.
_getExpiredPastes()  : array<string|int, mixed>
Returns up to batch size number of paste ids that have expired
getOpenSlot()  : int|string
Get next free slot for comment from postdate.
upgradePreV1Format()  : array<string|int, mixed>
Upgrade pre-version 1 pastes with attachment to version 1 format.
_getKey()  : string
returns the S3 storage object key for $pasteid in $this->_bucket.
_listAllObjects()  : array<string|int, mixed>
returns all objects in the given prefix.
_upload()  : bool
Uploads the payload in the $this->_bucket under the specified key.

Properties

$_last_cache

cache for the traffic limiter

protected array<string|int, mixed> $_last_cache = array()
Tags
access

protected

$_bucket

S3 bucket

private string $_bucket = null
Tags
access

private

$_client

S3 client

private S3Client $_client = null
Tags
access

private

$_options

S3 client options

private array<string|int, mixed> $_options = array()
Tags
access

private

$_prefix

S3 prefix for all PrivateBin data in this bucket

private string $_prefix = ''
Tags
access

private

Methods

__construct()

instantiates a new S3 data backend.

public __construct(array<string|int, mixed> $options) : mixed
Parameters
$options : array<string|int, mixed>
Tags
access

public

create()

Create a paste.

public create(mixed $pasteid, array<string|int, mixed> $paste) : bool
Parameters
$pasteid : mixed
$paste : array<string|int, mixed>
Tags
inheritDoc
Return values
bool

createComment()

Create a comment in a paste.

public createComment(mixed $pasteid, mixed $parentid, mixed $commentid, array<string|int, mixed> $comment) : bool
Parameters
$pasteid : mixed
$parentid : mixed
$commentid : mixed
$comment : array<string|int, mixed>
Tags
inheritDoc
Return values
bool

delete()

Delete a paste and its discussion.

public delete(mixed $pasteid) : mixed
Parameters
$pasteid : mixed
Tags
inheritDoc

exists()

Test if a paste exists.

public exists(mixed $pasteid) : bool
Parameters
$pasteid : mixed
Tags
inheritDoc
Return values
bool

existsComment()

Test if a comment exists.

public existsComment(mixed $pasteid, mixed $parentid, mixed $commentid) : bool
Parameters
$pasteid : mixed
$parentid : mixed
$commentid : mixed
Tags
inheritDoc
Return values
bool

getAllPastes()

Returns all paste ids

public getAllPastes() : array<string|int, mixed>
Tags
inheritDoc
Return values
array<string|int, mixed>

getValue()

Load a value.

public getValue(mixed $namespace[, mixed $key = '' ]) : string
Parameters
$namespace : mixed
$key : mixed = ''
Tags
inheritDoc
Return values
string

purge()

Perform a purge of old pastes, at most the given batchsize is deleted.

public purge(int $batchsize) : mixed
Parameters
$batchsize : int
Tags
access

public

purgeValues()

Purge outdated entries.

public purgeValues(mixed $namespace, mixed $time) : void
Parameters
$namespace : mixed
$time : mixed
Tags
inheritDoc

read()

Read a paste.

public read(mixed $pasteid) : array<string|int, mixed>|false
Parameters
$pasteid : mixed
Tags
inheritDoc
Return values
array<string|int, mixed>|false

readComments()

Read all comments of paste.

public readComments(mixed $pasteid) : array<string|int, mixed>
Parameters
$pasteid : mixed
Tags
inheritDoc
Return values
array<string|int, mixed>

setValue()

For S3, the value will also be stored in the metadata for the namespaces traffic_limiter and purge_limiter.

public setValue(mixed $value, mixed $namespace[, mixed $key = '' ]) : bool
Parameters
$value : mixed
$namespace : mixed
$key : mixed = ''
Tags
inheritDoc
Return values
bool

_getExpiredPastes()

Returns up to batch size number of paste ids that have expired

protected _getExpiredPastes(mixed $batchsize) : array<string|int, mixed>
Parameters
$batchsize : mixed
Tags
inheritDoc
Return values
array<string|int, mixed>

getOpenSlot()

Get next free slot for comment from postdate.

protected getOpenSlot(array<string|int, mixed> &$comments, int|string $postdate) : int|string
Parameters
$comments : array<string|int, mixed>
$postdate : int|string
Tags
access

protected

Return values
int|string

upgradePreV1Format()

Upgrade pre-version 1 pastes with attachment to version 1 format.

protected static upgradePreV1Format(array<string|int, mixed> $paste) : array<string|int, mixed>
Parameters
$paste : array<string|int, mixed>
Tags
access

protected

static
Return values
array<string|int, mixed>

_getKey()

returns the S3 storage object key for $pasteid in $this->_bucket.

private _getKey( $pasteid) : string
Parameters
$pasteid :

string to get the key for

Tags
access

private

Return values
string

_listAllObjects()

returns all objects in the given prefix.

private _listAllObjects( $prefix) : array<string|int, mixed>
Parameters
$prefix :

string with prefix

Tags
access

private

Return values
array<string|int, mixed>

all objects in the given prefix

_upload()

Uploads the payload in the $this->_bucket under the specified key.

private _upload( $key,  $payload) : bool

The entire payload is stored as a JSON document. The metadata is replicated as the S3 object's metadata except for the fields attachment, attachmentname and salt.

Parameters
$key :

string to store the payload under

$payload :

array to store

Return values
bool

true if successful, otherwise false.


        
On this page

Search results