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
$_bucket
S3 bucket
private
string
$_bucket
= null
Tags
$_client
S3 client
private
S3Client
$_client
= null
Tags
$_options
S3 client options
private
array<string|int, mixed>
$_options
= array()
Tags
$_prefix
S3 prefix for all PrivateBin data in this bucket
private
string
$_prefix
= ''
Tags
Methods
__construct()
instantiates a new S3 data backend.
public
__construct(array<string|int, mixed> $options) : mixed
Parameters
- $options : array<string|int, mixed>
Tags
create()
Create a paste.
public
create(mixed $pasteid, array<string|int, mixed> $paste) : bool
Parameters
- $pasteid : mixed
- $paste : array<string|int, mixed>
Tags
Return values
boolcreateComment()
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
Return values
booldelete()
Delete a paste and its discussion.
public
delete(mixed $pasteid) : mixed
Parameters
- $pasteid : mixed
Tags
exists()
Test if a paste exists.
public
exists(mixed $pasteid) : bool
Parameters
- $pasteid : mixed
Tags
Return values
boolexistsComment()
Test if a comment exists.
public
existsComment(mixed $pasteid, mixed $parentid, mixed $commentid) : bool
Parameters
- $pasteid : mixed
- $parentid : mixed
- $commentid : mixed
Tags
Return values
boolgetAllPastes()
Returns all paste ids
public
getAllPastes() : array<string|int, mixed>
Tags
Return values
array<string|int, mixed>getValue()
Load a value.
public
getValue(mixed $namespace[, mixed $key = '' ]) : string
Parameters
- $namespace : mixed
- $key : mixed = ''
Tags
Return values
stringpurge()
Perform a purge of old pastes, at most the given batchsize is deleted.
public
purge(int $batchsize) : mixed
Parameters
- $batchsize : int
Tags
purgeValues()
Purge outdated entries.
public
purgeValues(mixed $namespace, mixed $time) : void
Parameters
- $namespace : mixed
- $time : mixed
Tags
read()
Read a paste.
public
read(mixed $pasteid) : array<string|int, mixed>|false
Parameters
- $pasteid : mixed
Tags
Return values
array<string|int, mixed>|falsereadComments()
Read all comments of paste.
public
readComments(mixed $pasteid) : array<string|int, mixed>
Parameters
- $pasteid : mixed
Tags
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
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
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
Return values
int|stringupgradePreV1Format()
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
Return values
array<string|int, mixed>_getKey()
returns the S3 storage object key for $pasteid in $this->_bucket.
private
_getKey( $pasteid) : string
Parameters
Tags
Return values
string_listAllObjects()
returns all objects in the given prefix.
private
_listAllObjects( $prefix) : array<string|int, mixed>
Parameters
Tags
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
Return values
bool —true if successful, otherwise false.