\StorageBox

Represents a key-value data store.

Summary

Methods
Properties
Constants
__construct()
has()
get_keys()
get()
get_arr_simple()
set()
set_arr_simple()
delete()
clear()
close()
No public properties found
MODE_JSON
MODE_ARR_SIMPLE
No protected methods found
No protected properties found
N/A
No private methods found
No private properties found
N/A

Constants

MODE_JSON

MODE_JSON

MODE_ARR_SIMPLE

MODE_ARR_SIMPLE

Methods

__construct()

__construct(string  $filename)

Initialises a new store connection.

Parameters

string $filename

The filename that the store is located in.

has()

has(string  $key): boolean

Determines if the given key exists in the store or not.

Parameters

string $key

The key to test.

Returns

boolean —

Whether the key exists in the store or not.

get_keys()

get_keys(string  $exclude): \PDOStatement

Returns an iterable that returns all the keys that do not contain the given string.

Parameters

string $exclude

The string to search for when excluding keys.

Returns

\PDOStatement —

The iterable. Use a foreach loop on it.

get()

get(string  $key): mixed

Gets a value from the store.

Parameters

string $key

The key value is stored under.

Returns

mixed —

The stored value.

get_arr_simple()

get_arr_simple(\string  $key,\string  $delimiter = "|")

Parameters

\string $key
\string $delimiter

set()

set(string  $key,mixed  $value)

Sets a value in the data store.

Note that this does NOT save changes to disk until you close the connection!

Parameters

string $key

The key to set the value of.

mixed $value

The value to store.

set_arr_simple()

set_arr_simple(\string  $key,  $value,\string  $delimiter = "|")

Parameters

\string $key
$value
\string $delimiter

delete()

delete(string  $key): boolean

Deletes an item from the data store.

Parameters

string $key

The key of the item to delete.

Returns

boolean —

Whether it was really deleted or not. Note that if it doesn't exist, then it can't be deleted.

clear()

clear()

Empties the store.

close()

close()

Syncs changes to disk and closes the PDO connection.