PHPackages                             rkr/key-value-stores - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. rkr/key-value-stores

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

rkr/key-value-stores
====================

Standard interfaces for common key-value-stores.

0.0.3.1(11y ago)3133[1 issues](https://github.com/rkrx/php-key-value-stores/issues)MITPHPPHP &gt;= 5.3

Since Feb 5Pushed 11y ago3 watchersCompare

[ Source](https://github.com/rkrx/php-key-value-stores)[ Packagist](https://packagist.org/packages/rkr/key-value-stores)[ RSS](/packages/rkr-key-value-stores/feed)WikiDiscussions master Synced 2w ago

READMEChangelog (4)Dependencies (1)Versions (5)Used By (0)

php-key-value-stores
====================

[](#php-key-value-stores)

[![Travis](https://camo.githubusercontent.com/d308692376cadc203451e8c4a510f45d01ee3a661cc44dede10fd5a0395b2a32/68747470733a2f2f7472617669732d63692e6f72672f726b72782f7068702d6b65792d76616c75652d73746f7265732e737667)](https://travis-ci.org/rkrx/php-key-value-stores)

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.

Common interfaces
-----------------

[](#common-interfaces)

### Stores

[](#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:

```
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](http://en.wikipedia.org/wiki/Interface_segregation_principle).

[![Inheritance](assets/diagram.png)](assets/diagram.png)

#### Behavior of stores

[](#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).

`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.

`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.

`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).

### Contexts

[](#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.

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.

### Valid types

[](#valid-types)

#### Valid key-type

[](#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.

#### Valid value-type

[](#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`.

### Standard-tests

[](#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`.

Installation via composer
-------------------------

[](#installation-via-composer)

composer require "rkr/php-key-value-stores" "~v0.0"

###  Health Score

24

—

LowBetter than 31% of packages

Maintenance13

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity51

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~87 days

Total

4

Last Release

4264d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/7f83d7e57a4bf3f1309680dbfbbf2d022f0ee6dae64a4b3bdfbed1226f2f6bef?d=identicon)[rkr](/maintainers/rkr)

---

Top Contributors

[![rkrx](https://avatars.githubusercontent.com/u/5672982?v=4)](https://github.com/rkrx "rkrx (32 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/rkr-key-value-stores/health.svg)

```
[![Health](https://phpackages.com/badges/rkr-key-value-stores/health.svg)](https://phpackages.com/packages/rkr-key-value-stores)
```

###  Alternatives

[raoul2000/yii2-scrollup-widget

Wrapper around the Scrollup JQuery plugin

133.4k](/packages/raoul2000-yii2-scrollup-widget)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
