Overview

Namespaces

  • Webmozart
    • KeyValueStore
      • Api
      • Decorator
      • Util

Classes

  • AbstractRedisStore
  • ArrayStore
  • DbalStore
  • JsonFileStore
  • MongoDbStore
  • NullStore
  • PhpRedisStore
  • PredisStore
  • RiakStore
  • SerializingArrayStore
  • Overview
  • Namespace
  • Class

Class JsonFileStore

A key-value store backed by a JSON file.

Webmozart\KeyValueStore\JsonFileStore implements Webmozart\KeyValueStore\Api\SortableStore, Webmozart\KeyValueStore\Api\CountableStore
Namespace: Webmozart\KeyValueStore
Since: 1.0
Author: Bernhard Schussek bschussek@gmail.com
Located at JsonFileStore.php
Methods summary
public
# __construct( $path, $flags = 0 )
public
# set( integer|string $key, mixed $value )

Sets the value for a key in the store.

Sets the value for a key in the store.

Parameters

$key
The key to set.
$value
The value to set for the key.

Throws

Webmozart\KeyValueStore\Api\WriteException
If the store cannot be written.
InvalidKeyException
If the key is not a string or integer.
SerializationFailedException
If the value cannot be serialized.
Webmozart\KeyValueStore\Api\UnsupportedValueException

If the value is not supported by the implementation.

Implementation of

Webmozart\KeyValueStore\Api\KeyValueStore::set()
public mixed
# get( integer|string $key, mixed $default = null )

Returns the value of a key in the store.

Returns the value of a key in the store.

Parameters

$key
The key to get.
$default

The default value to return if the key does not exist.

Returns

mixed

The value of the key or the default value if the key does not exist.

Throws

Webmozart\KeyValueStore\Api\ReadException
If the store cannot be read.
InvalidKeyException
If the key is not a string or integer.
UnserializationFailedException

If the stored value cannot be unserialized.

Implementation of

Webmozart\KeyValueStore\Api\KeyValueStore::get()
public mixed
# getOrFail( integer|string $key )

Returns the value of a key in the store.

Returns the value of a key in the store.

Parameters

$key
The key to get.

Returns

mixed
The value of the key.

Throws

Webmozart\KeyValueStore\Api\ReadException
If the store cannot be read.
Webmozart\KeyValueStore\Api\NoSuchKeyException
If the key was not found.
InvalidKeyException
If the key is not a string or integer.
UnserializationFailedException

If the stored value cannot be unserialized.

Implementation of

Webmozart\KeyValueStore\Api\KeyValueStore::getOrFail()
public array
# getMultiple( array $keys, mixed $default = null )

Returns the values of multiple keys in the store.

Returns the values of multiple keys in the store.

Parameters

$keys
The keys to get. The keys must be strings or integers.
$default

The default value to return for keys that are not found.

Returns

array
The values of the passed keys, indexed by the keys.

Throws

Webmozart\KeyValueStore\Api\ReadException
If the store cannot be read.
InvalidKeyException
If a key is not a string or integer.
UnserializationFailedException

If a stored value cannot be unserialized.

Implementation of

Webmozart\KeyValueStore\Api\KeyValueStore::getMultiple()
public array
# getMultipleOrFail( array $keys )

Returns the values of multiple keys in the store.

Returns the values of multiple keys in the store.

Parameters

$keys
The keys to get. The keys must be strings or integers.

Returns

array
The values of the passed keys, indexed by the keys.

Throws

Webmozart\KeyValueStore\Api\ReadException
If the store cannot be read.
Webmozart\KeyValueStore\Api\NoSuchKeyException
If a key was not found.
InvalidKeyException
If a key is not a string or integer.
UnserializationFailedException

If a stored value cannot be unserialized.

Implementation of

Webmozart\KeyValueStore\Api\KeyValueStore::getMultipleOrFail()
public boolean
# remove( integer|string $key )

Removes a key from the store.

Removes a key from the store.

Parameters

$key
The key to remove.

Returns

boolean
Returns true if a key was removed from the store.

Throws

Webmozart\KeyValueStore\Api\WriteException
If the store cannot be written.
InvalidKeyException
If the key is not a string or integer.

Implementation of

Webmozart\KeyValueStore\Api\KeyValueStore::remove()
public boolean
# exists( integer|string $key )

Returns whether a key exists.

Returns whether a key exists.

Parameters

$key
The key to test.

Returns

boolean
Whether the key exists in the store.

Throws

Webmozart\KeyValueStore\Api\ReadException
If the store cannot be read.
InvalidKeyException
If the key is not a string or integer.

Implementation of

Webmozart\KeyValueStore\Api\KeyValueStore::exists()
public
# clear( )

Removes all keys from the store.

Removes all keys from the store.

Throws

Webmozart\KeyValueStore\Api\WriteException
If the store cannot be written.

Implementation of

Webmozart\KeyValueStore\Api\KeyValueStore::clear()
public array
# keys( )

Returns all keys currently stored in the store.

Returns all keys currently stored in the store.

Returns

array

The keys stored in the store. Each key is either a string or an integer. The order of the keys is undefined.

Throws

Webmozart\KeyValueStore\Api\ReadException
If the store cannot be read.

Implementation of

Webmozart\KeyValueStore\Api\KeyValueStore::keys()
public
# sort( integer $flags = SORT_REGULAR )

Sort the store by its keys.

Sort the store by its keys.

Parameters

$flags
Sorting type flags (from the standard PHP sort flags).

Throws

Webmozart\KeyValueStore\Api\ReadException
If the store cannot be read.
Webmozart\KeyValueStore\Api\WriteException
If the store cannot be written.

Implementation of

Webmozart\KeyValueStore\Api\SortableStore::sort()
public
# count( )

Count the number of keys in the store.

Count the number of keys in the store.

Throws

Webmozart\KeyValueStore\Api\ReadException
If the store cannot be read.

Implementation of

Webmozart\KeyValueStore\Api\CountableStore::count()
Constants summary
integer NO_SERIALIZE_STRINGS

Flag: Disable serialization of strings.

Flag: Disable serialization of strings.

# 1
integer NO_SERIALIZE_ARRAYS

Flag: Disable serialization of arrays.

Flag: Disable serialization of arrays.

# 2
integer ESCAPE_GT_LT

Flag: Escape ">" and "<".

Flag: Escape ">" and "<".

# 4
integer ESCAPE_AMPERSAND

Flag: Escape "&".

Flag: Escape "&".

# 8
integer ESCAPE_SINGLE_QUOTE

Flag: Escape single quotes.

Flag: Escape single quotes.

# 16
integer ESCAPE_DOUBLE_QUOTE

Flag: Escape double quotes.

Flag: Escape double quotes.

# 32
integer NO_ESCAPE_SLASH

Flag: Don't escape forward slashes.

Flag: Don't escape forward slashes.

# 64
integer NO_ESCAPE_UNICODE

Flag: Don't escape Unicode characters.

Flag: Don't escape Unicode characters.

# 128
integer PRETTY_PRINT

Flag: Format the JSON nicely.

Flag: Format the JSON nicely.

# 256
integer TERMINATE_WITH_LINE_FEED

Flag: Terminate the JSON with a line feed.

Flag: Terminate the JSON with a line feed.

# 512
float MAX_FLOAT

This seems to be the biggest float supported by json_encode()/json_decode().

This seems to be the biggest float supported by json_encode()/json_decode().

# 1.0E+14
Webmozart Key-Value Store API API documentation generated by ApiGen