Properties

$_last_cache

$_last_cache :array

cache for the traffic limiter

Type

array

$_client

$_client :\Aws\S3\S3Client

S3 client

Type

\Aws\S3\S3Client

$_options

$_options :array

S3 client options

Type

array

$_bucket

$_bucket :string

S3 bucket

Type

string

$_prefix

$_prefix :string

S3 prefix for all PrivateBin data in this bucket

Type

string

Methods

create()

create(string  $pasteid,array  $paste): boolean

Create a paste.

Parameters

string $pasteid
array $paste

Returns

boolean

read()

read(string  $pasteid): array|false

Read a paste.

Parameters

string $pasteid

Returns

array|false

delete()

delete(string  $pasteid)

Delete a paste and its discussion.

Parameters

string $pasteid

exists()

exists(string  $pasteid): boolean

Test if a paste exists.

Parameters

string $pasteid

Returns

boolean

createComment()

createComment(string  $pasteid,string  $parentid,string  $commentid,array  $comment): boolean

Create a comment in a paste.

Parameters

string $pasteid
string $parentid
string $commentid
array $comment

Returns

boolean

readComments()

readComments(string  $pasteid): array

Read all comments of paste.

Parameters

string $pasteid

Returns

array

existsComment()

existsComment(string  $pasteid,string  $parentid,string  $commentid): boolean

Test if a comment exists.

Parameters

string $pasteid
string $parentid
string $commentid

Returns

boolean

purgeValues()

purgeValues(string  $namespace,integer  $time): void

Purge outdated entries.

Parameters

string $namespace
integer $time

setValue()

setValue(string  $value,string  $namespace,string  $key = ''): boolean

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

Parameters

string $value
string $namespace
string $key

Returns

boolean

getValue()

getValue(string  $namespace,string  $key = ''): string

Load a value.

Parameters

string $namespace
string $key

Returns

string

purge()

purge(integer  $batchsize)

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

Parameters

integer $batchsize

getAllPastes()

getAllPastes(): array

Returns all paste ids

Returns

array

__construct()

__construct(array  $options): 

instantiates a new S3 data backend.

Parameters

array $options

Returns

_getExpiredPastes()

_getExpiredPastes(integer  $batchsize): array

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

Parameters

integer $batchsize

Returns

array

getOpenSlot()

getOpenSlot(array  $comments,integer|string  $postdate): integer|string

Get next free slot for comment from postdate.

Parameters

array $comments
integer|string $postdate

Returns

integer|string

upgradePreV1Format()

upgradePreV1Format(array  $paste): array

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

Parameters

array $paste

Returns

array

_listAllObjects()

_listAllObjects(  $prefix): array

returns all objects in the given prefix.

Parameters

$prefix

string with prefix

Returns

array —

all objects in the given prefix

_getKey()

_getKey(  $pasteid): string

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

Parameters

$pasteid

string to get the key for

Returns

string

_upload()

_upload(  $key,  $payload): boolean

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

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

Returns

boolean —

true if successful, otherwise false.