PHP Classes

Key-Value Storage: Store and retrieve values on different containers

Recommend this page to a friend!
  Info   Documentation   View files Files   Install with Composer Install with Composer   Download Download   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not yet rated by the usersTotal: 120 All time: 9,510 This week: 455Up
Version License PHP version Categories
kv_storage 1.0.2MIT/X Consortium ...5PHP 5, Databases, Files and Folders
Description 

Author

This package can store and retrieve values on different containers.

It provides several classes that can check, store, retrieve, update and delete value for given keys on several types of containers.

Currently it provides container classes for storing data in memory, files, MongoDB databases.

Picture of Payam Naderi
  Performance   Level  
Innovation award
Innovation award
Nominee: 2x

 

Documentation

Storage

InMemory Store

// Storage for 'test' Realm.

$s = new InMemoryStore('test');
$s->set('name', 'Payam');
$s->set('family', 'Naderi');

$fullname = $s->getFromKeys(['name', 'family']);
$fullname = StdTravers::of($fullname)
    ->each(function($val, $_ ,$prev) {
        return $prev.= ' '.$val;
    });

print_r($fullname);

FlatFile Store

$s = new FlatFileStore('user_codes');
        
$user_id = 'd5e110k33f';
$s->set($user_id, '1453');
// Without this syntax storage will save given entity when dispatch shutdown.
$s->save(); // force to save current 

> In Next Calls

values can be retrieved.

$s = new FlatFileStore('user_codes');
if ($s->has('d5e110k33f'))
    print_r($s->get('d5e110k33f'));

> Destroy Storage

will destroy storage for given 'user_codes' realm.

$s = new FlatFileStore('user_codes');
$s->destroy();

> Choose Desired Options

Options In under_score with construct

$s = new FlatFileStore('user_codes', ['dir_path' => __DIR__.'/my_user_codes.dat']);
$s->set('key', 'value');

will map to setter methods

$s = new FlatFileStore('user_codes');
$s->setPathDir(__DIR__.'/my_user_codes.dat');
$s->set('key', 'value');

Mongo Store

$client     = \Module\MongoDriver\Actions::Driver()->getClient('master');
$collection = $client->selectCollection('papioniha', 'store.app');

$s = new MongoStore('pass_trough', ['collection' => $collection]);

// Traverse All Data

$v = StdTravers::of( $s )
    ->each(function($val, $key ,$prev) {
        if ( is_array($prev) )
            return $prev[$key] = $val;

        return [$key => $val];
    });

print_r($v);

  Files folder image Files (26)  
File Role Description
Files folder imagesrc (6 files, 6 directories)
Accessible without login Plain text file composer.json Data Auxiliary data
Accessible without login Plain text file LICENSE Lic. License text
Accessible without login Plain text file readme.md Doc. Documentation

The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page.
Install with Composer Install with Composer
 Version Control Unique User Downloads Download Rankings  
 100%
Total:120
This week:0
All time:9,510
This week:455Up