2017 © Pedro Peláez
 

library flintstone

A key/value database store using flat files for PHP

image

fire015/flintstone

A key/value database store using flat files for PHP

  • Friday, February 2, 2018
  • by fire015
  • Repository
  • 14 Watchers
  • 232 Stars
  • 15,946 Installations
  • PHP
  • 8 Dependents
  • 0 Suggesters
  • 26 Forks
  • 0 Open issues
  • 11 Versions
  • 5 % Grown

The README.md

Flintstone

Total Downloads Build Status, (*1)

A key/value database store using flat files for PHP., (*2)

Features include:, (*3)

  • Memory efficient
  • File locking
  • Caching
  • Gzip compression
  • Easy to use

Installation

The easiest way to install Flintstone is via composer. Run the following command to install it., (*4)

composer require fire015/flintstone
<?php
require 'vendor/autoload.php';

use Flintstone\Flintstone;

$users = new Flintstone('users', ['dir' => '/path/to/database/dir/']);

Requirements

  • PHP 7.3+

Data types

Flintstone can store any data type that can be formatted into a string. By default this uses serialize(). See Changing the formatter for more details., (*5)

Options

Name Type Default Value Description
dir string the current working directory The directory where the database files are stored (this should be somewhere that is not web accessible) e.g. /path/to/database/
ext string .dat The database file extension to use
gzip boolean false Use gzip to compress the database
cache boolean or object true Whether to cache get() results for faster data retrieval
formatter null or object null The formatter class used to encode/decode data
swap_memory_limit integer 2097152 The amount of memory to use before writing to a temporary file

Usage examples

<?php

// Load a database
$users = new Flintstone('users', ['dir' => '/path/to/database/dir/']);

// Set a key
$users->set('bob', ['email' => 'bob@site.com', 'password' => '123456']);

// Get a key
$user = $users->get('bob');
echo 'Bob, your email is ' . $user['email'];

// Retrieve all key names
$keys = $users->getKeys(); // returns array('bob')

// Retrieve all data
$data = $users->getAll(); // returns array('bob' => array('email' => 'bob@site.com', 'password' => '123456'));

// Delete a key
$users->delete('bob');

// Flush the database
$users->flush();

Changing the formatter

By default Flintstone will encode/decode data using PHP's serialize functions, however you can override this with your own class if you prefer., (*6)

Just make sure it implements Flintstone\Formatter\FormatterInterface and then you can provide it as the formatter option., (*7)

If you wish to use JSON as the formatter, Flintstone already ships with this as per the example below:, (*8)

<?php
require 'vendor/autoload.php';

use Flintstone\Flintstone;
use Flintstone\Formatter\JsonFormatter;

$users = new Flintstone('users', [
    'dir' => __DIR__,
    'formatter' => new JsonFormatter()
]);

Changing the cache

To speed up data retrieval Flintstone can store the results of get() in a cache store. By default this uses a simple array that only persist's for as long as the Flintstone object exists., (*9)

If you want to use your own cache store (such as Memcached) you can pass a class as the cache option. Just make sure it implements Flintstone\Cache\CacheInterface., (*10)

The Versions

02/02 2018

dev-master

9999999-dev http://www.xeweb.net/flintstone/

A key/value database store using flat files for PHP

  Sources   Download

MIT

The Requires

  • php >=5.6

 

The Development Requires

by Jason M

database cache files flintstone memory

09/06 2017

v2.1.1

2.1.1.0 http://www.xeweb.net/flintstone/

A key/value database store using flat files for PHP

  Sources   Download

MIT

The Requires

  • php >=5.6

 

The Development Requires

by Jason M

database cache files flintstone memory

24/05 2017

dev-develop

dev-develop http://www.xeweb.net/flintstone/

A key/value database store using flat files for PHP

  Sources   Download

MIT

The Requires

  • php >=5.6

 

The Development Requires

by Jason M

database cache files flintstone memory

24/05 2017

v2.1.0

2.1.0.0 http://www.xeweb.net/flintstone/

A key/value database store using flat files for PHP

  Sources   Download

MIT

The Requires

  • php >=5.6

 

The Development Requires

by Jason M

database cache files flintstone memory

21/01 2016

v2.0.0

2.0.0.0 http://www.xeweb.net/flintstone/

A key/value database store using flat files for PHP

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

The Development Requires

by Jason M

database cache files flintstone memory

25/03 2015

v1.9.0

1.9.0.0 http://www.xeweb.net/flintstone/

A key/value database store using flat files for PHP

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

The Development Requires

by Jason M

database cache files flintstone memory

15/10 2014

v1.8.0

1.8.0.0 http://www.xeweb.net/flintstone/

A key/value database store using flat files for PHP

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

The Development Requires

by Jason M

database cache files flintstone memory

09/10 2014

v1.7.0

1.7.0.0 http://www.xeweb.net/flintstone/

A key/value database store using flat files for PHP

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

The Development Requires

by Jason M

database cache files flintstone memory

30/09 2014

v1.6.0

1.6.0.0 http://www.xeweb.net/flintstone/

A key/value database store using flat files for PHP

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

by Jason M

database cache files flintstone memory

29/05 2014

v1.5.0

1.5.0.0 http://www.xeweb.net/flintstone/

A key/value database store using flat files for PHP

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

The Development Requires

by Jason M

database cache files flintstone memory

11/03 2014

v1.4.0

1.4.0.0 http://www.xeweb.net/flintstone/

A key/value database store using flat files for PHP

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

The Development Requires

by Jason M

database cache files flintstone memory