2017 © Pedro Peláez
 

library key-value-stores

Standard interfaces for common key-value-stores.

image

rkr/key-value-stores

Standard interfaces for common key-value-stores.

  • Sunday, October 26, 2014
  • by rkr
  • Repository
  • 2 Watchers
  • 2 Stars
  • 101 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 0 Forks
  • 1 Open issues
  • 5 Versions
  • 0 % Grown

The README.md

php-key-value-stores

Travis, (*1)

This project aims to provide a standard interface to common key-value-stores like memcache, redis or similar. If an author of a specific driver develops against these interfaces, is can be used everywhere the interfaces are implemented. This project does not ship a concrete implementations to existing stores., (*2)

Common interfaces

Stores

The simple version of the key value stores provide methods to set, get and remove a entry. There is also a method to test if a entry is existing:, (*3)

interface ReadWriteStore
    public function has($key);
    public function get($key, $default=null);
    public function set($key, $value);
    public function remove($key);

The ReadWriteStore-Interface has no own methods. It extends the 2 Interfaces ReadableStore and WritableStore which in turn extend from other, more basic interfaces. The idea behind this is described here., (*4)

Inheritance, (*5)

Behavior of stores

has() returns true when a key exists in the store and false if not. In addition to that, it throws an exception when $key is not a valid type (see valid types)., (*6)

get() returns the content of a entry, referenced by $key. If the entry was not found, get() then returns $default. $default must be a value value-type. In addition to that, an InvalidArgumentException or deriving gets thrown when $key is not a valid key-type (see valid types) and an InvalidOperationException or deriving gets thrown for store specific reasons., (*7)

set() sets the value of an entry. If the corresponding entry does not exist, set will create it. If the entry already exists, set will overwrite its content. set() returns $this for a fluent interface. In addition to that, an InvalidArgumentException or deriving gets thrown when $key is not a valid key-type (see valid types) and an InvalidOperationException or deriving gets thrown for store specific reasons., (*8)

remove() removes an entry from a store. It throws an InvalidOperationException or deriving if this operation fails, caused by a missing entry or another process failure. In addition to that, an InvalidArgumentException or deriving gets thrown when $key is not a valid key-type (see valid types)., (*9)

Contexts

A context is similar to a table in a RDBMS. With contexts, you can separate stores for different environments or components. So a context is like a central singleton-repository for stores., (*10)

For example, a context could be used to define a database connection. Every store created by that context inherit that connection and possibly some metadata too., (*11)

Valid types

Valid key-type

A key is valid if it is a string, int or object with a __toString() method. The store must not serialize and/or hash a key to convert any object to a string., (*12)

Valid value-type

A value (or default-value) is valid under the same criterias as a key-type. A default-value is also allowed to be null., (*13)

Standard-tests

A store-author can make use of the provided standardtests to ensure compilance. So far, there are only tests for the ReadWriteStore and the Contexts. The tests are based in phpunit 3.7., (*14)

Installation via composer

composer require "rkr/php-key-value-stores" "~v0.0", (*15)

The Versions

26/10 2014

dev-master

9999999-dev

Standard interfaces for common key-value-stores.

  Sources   Download

MIT

The Requires

  • php >= 5.3

 

The Development Requires

by Ron

26/10 2014

0.0.3.1

0.0.3.1

Standard interfaces for common key-value-stores.

  Sources   Download

MIT

The Requires

  • php >= 5.3

 

The Development Requires

by Ron

27/03 2014

0.0.3

0.0.3.0

Standard interfaces for common key-value-stores.

  Sources   Download

MIT

The Requires

  • php >= 5.3

 

The Development Requires

by Ron

05/02 2014

0.0.2

0.0.2.0 https://github.com/rkrx/php-key-value-stores

This is a cache system that uses Redis for rapid caching.

  Sources   Download

MIT

The Requires

  • php >= 5.3

 

The Development Requires

05/02 2014

0.0.1

0.0.1.0 https://github.com/rkrx/php-key-value-stores

This is a cache system that uses Redis for rapid caching.

  Sources   Download

MIT

The Requires

  • php >= 5.3