GoogleCloudStorage
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 : Bucket
- GCS bucket
- $_client : StorageClient
- GCS client
- $_prefix : string
- object prefix
- $_uniformacl : bool
- bucket acl type
Methods
- __construct() : mixed
- instantiantes a new Google Cloud Storage 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 GoogleCloudStorage, 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 google storage object key for $pasteid in $this->_bucket.
- _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
GCS bucket
private
Bucket
$_bucket
= null
Tags
$_client
GCS client
private
StorageClient
$_client
= null
Tags
$_prefix
object prefix
private
string
$_prefix
= 'pastes'
Tags
$_uniformacl
bucket acl type
private
bool
$_uniformacl
= false
Tags
Methods
__construct()
instantiantes a new Google Cloud Storage 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 GoogleCloudStorage, 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 google storage object key for $pasteid in $this->_bucket.
private
_getKey( $pasteid) : string
Parameters
Tags
Return values
string_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 GCS object's metadata except for the fields attachment, attachmentname and salt.
Parameters
Return values
bool —true if successful, otherwise false.