kmfk/slowdb

There is no license information available for the latest version (1.0.13) of this package.

A Key/Value Store written in PHP

1.0.13 2015-03-16 17:56 UTC

This package is not auto-updated.

Last update: 2024-04-22 23:46:28 UTC


README

SlowDB

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:

  • 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

Clone the repository locally and run composer install:

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

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) and the driver.

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

$> ./slowdb &

Basic Example

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

    <?php

    require 'vendor/autoload.php';

    use SlowDB\Driver;

    $driver = new Driver('localhost', 1337);

    $driver->test->set('abc', ['foo' => 'bar']);

    $value = $driver->test->get('abc');

    print_r($value);