mthenw / nosqlite
Simple key => value store based on SQLite3
Installs: 2 175
Dependents: 3
Suggesters: 0
Security: 0
Stars: 48
Watchers: 6
Forks: 8
Open Issues: 1
Requires
- php: >=5.3.2
Requires (Dev)
- phpunit/phpunit: 3.7.*@stable
- squizlabs/php_codesniffer: 1.4.*@stable
This package is not auto-updated.
Last update: 2024-11-09 12:37:46 UTC
README
Introduction
NoSQLite is simple key-value store using SQLite as raw data store. Mainly for small project where MySQL is too heavy and files are too ugly.
Requirements
- PHP >=5.3.2
- PDO (by default as of PHP 5.1.0)
- PDO_SQLITE (by default as of PHP 5.1.0)
Installing via Composer
Get composer and add following lines to composer.json
:
{
"require": {
"mthenw/nosqlite": "*@stable"
}
}
Usage
-
Create stores' manager (file will be created if not exists)
$nsql = new NoSQLite\NoSQLite('mydb.sqlite');
-
Get store
$store = $nsql->getStore('movies');
-
Set value in store (key and value max length are limited by SQLite TEXT datatype)
$store->set(uniqid(), json_encode(array('title' => 'Good Will Hunting', 'director' => 'Gus Van Sant')));
-
Get value from store (will be created if not exists)
$store->get('3452345');
-
Get all values
$store->getAll();
-
Delete all values
$store->deleteAll();
-
Iterate through store (Store implements Iterator interface)
foreach($store as $key => $value) ...
-
Get number of values in store (Store implements Countable interface)
count($store);
Tests
Tests are written in PHPUnit which is required as a dev package in composer.json
. For running test use
./vendor/bin/phpunit
or simply
make test