PHPackages                             kmfk/slowdb - 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. [Database &amp; ORM](/categories/database)
4. /
5. kmfk/slowdb

ActiveLibrary[Database &amp; ORM](/categories/database)

kmfk/slowdb
===========

A Key/Value Store written in PHP

1.0.13(11y ago)639PHP

Since Sep 29Pushed 11y ago1 watchersCompare

[ Source](https://github.com/kmfk/slowdb)[ Packagist](https://packagist.org/packages/kmfk/slowdb)[ RSS](/packages/kmfk-slowdb/feed)WikiDiscussions master Synced 6d ago

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

SlowDB
======

[](#slowdb)

[![SlowDB](slowdb.jpg)](slowdb.jpg)

When you don't want Redis, Memcached, or any other Key/Value store.

SlowDB is the Key/Value store written purely in PHP that'd you be upset to find your co-worker running in production.

### Features:

[](#features)

- Multiple named Collections
- In-memory indexes
- Safe persistence to disk

SlowDB allows for storing Key/Value pairs in multiple collections. Indexes are built/rebuilt on startup to map Keys to file locations on disk. This allows performant binary searches across database files and writing directly to disk for safe, consistent writes.

### Installation

[](#installation)

Clone the repository locally and run [composer](https://getcomposer.org/download/) install:

```
$> git clone https://github.com/kmfk/slowdb
$> cd slowdb/
$> php composer.phar install

```

### Usage

[](#usage)

Technically, SlowDB can be instantiated as a service in your application.

However, when SlowDB is used as a service, the Database needs to be instantiated and the indexes built on every request. On small datasets, this should be negligible - while large datasets, this can add unwanted latency to requests.

The best way to use SlowDB is by using the included socket server (built on [ReactPHP](https://github.com/reactphp/socket)) and the [driver](src/Driver.php).

While only single threaded, this will keep the database indexes in memory and provide better performance.

```
$> ./slowdb &

```

### Basic Example

[](#basic-example)

Once the server is running, you can use it like this:

```
