A KeyCache which streams to and from disk.

package Swift
subpackage KeyCache
author Chris Corbyn

 Methods

Create a new DiskKeyCache with the given $stream for cloning to make InputByteStreams, and the given $path to save to.

__construct(\Swift_KeyCache_KeyCacheInputStream $stream, string $path) 

Parameters

$path

string

to save to

Destructor.

__destruct() 

Clear all data in the namespace $nsKey if it exists.

clearAll(string $nsKey) 

Parameters

$nsKey

string

Clear data for $itemKey in the namespace $nsKey if it exists.

clearKey(string $nsKey, string $itemKey) 

Parameters

$nsKey

string

$itemKey

string

Get data back out of the cache as a ByteStream.

exportToByteStream(string $nsKey, string $itemKey, \Swift_InputByteStream $is) 

Parameters

$nsKey

string

$itemKey

string

$is

\Swift_InputByteStream

to write the data to

Provides a ByteStream which when written to, writes data to $itemKey.

getInputByteStream(string $nsKey, string $itemKey, \Swift_InputByteStream $writeThrough) : \Swift_InputByteStream

NOTE: The stream will always write in append mode.

Parameters

$nsKey

string

$itemKey

string

$writeThrough

Returns

Get data back out of the cache as a string.

getString(string $nsKey, string $itemKey) : string

Parameters

$nsKey

string

$itemKey

string

Exceptions

\Swift_IoException

Returns

string

Check if the given $itemKey exists in the namespace $nsKey.

hasKey(string $nsKey, string $itemKey) : boolean

Parameters

$nsKey

string

$itemKey

string

Returns

boolean

Set a ByteStream into the cache under $itemKey for the namespace $nsKey.

importFromByteStream(string $nsKey, string $itemKey, \Swift_OutputByteStream $os, int $mode) 
see MODE_APPEND

Parameters

$nsKey

string

$itemKey

string

$mode

int

Exceptions

\Swift_IoException

Set a string into the cache under $itemKey for the namespace $nsKey.

setString(string $nsKey, string $itemKey, string $string, int $mode) 
see MODE_APPEND

Parameters

$nsKey

string

$itemKey

string

$string

string

$mode

int

Exceptions

\Swift_IoException

_freeHandle()

_freeHandle($nsKey, $itemKey) 

Parameters

$nsKey

$itemKey

Get a file handle on the cache item.

_getHandle(string $nsKey, string $itemKey, int $position) : resource
access private

Parameters

$nsKey

string

$itemKey

string

$position

int

Returns

resource

Initialize the namespace of $nsKey if needed.

_prepareCache(string $nsKey) 
access private

Parameters

$nsKey

string

 Properties

 

$_keys : array
access private
 

$_path : string
access private
 

$_quotes : boolean
access private
 

$_stream : \Swift_KeyCache_KeyCacheInputStream
access private

 Constants

 

Mode for appending data to the end of existing cached data

MODE_APPEND 
Inherited
inherited_from \Swift_KeyCache::MODE_APPEND
 

Mode for replacing existing cached data

MODE_WRITE 
Inherited
inherited_from \Swift_KeyCache::MODE_WRITE
 

Signal to leave pointer in whatever position it currently is

POSITION_CURRENT 
 

Signal to place pointer at end of file

POSITION_END 
 

Signal to place pointer at start of file

POSITION_START