\JsonStorageBox

Represents a key-value data store.

Summary

Methods
Properties
Constants
__construct()
has()
get()
set()
delete()
clear()
close()
No public properties found
No constants found
No protected methods found
No protected properties found
N/A
No private methods found
No private properties found
N/A

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()

get(string  $key): mixed

Gets a value from the store.

Parameters

string $key

The key value is stored under.

Returns

mixed —

The stored value.

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.

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. Note also that if a node is deleted before being persisted to disk, this will return false when in actuality it was deleted successfully.

clear()

clear()

Empties the store.

close()

close()

Syncs changes to disk and closes the PDO connection.