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,503 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  
Name: Payam Naderi <contact>
Classes: 15 packages by
Country: United States United States
Age: 41
All time rank: 2017286 in United States United States
Week rank: 197 Up20 in United States United States Up
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

  Files folder image Files (26)  /  src  
File Role Description
Files folder imageException (4 files, 1 directory)
Files folder imageHttp (2 files)
Files folder imageInterchange (3 files)
Files folder imageInterfaces (2 files)
Files folder imageRedis (2 files)
Files folder imageWrapper (1 file)
  Plain text file aDataStore.php Class Class source
  Plain text file FlatFileStore.php Class Class source
  Plain text file InMemoryStore.php Class Class source
  Plain text file MongoStore.php Class Class source
  Plain text file RedisStore.php Class Class source
  Accessible without login Plain text file _functions.php Aux. Auxiliary script

  Files folder image Files (26)  /  src  /  Exception  
File Role Description
Files folder imageStorage (3 files)
  Plain text file exDataMalformed.php Class Class source
  Plain text file exDataNotPersistable.php Class Class source
  Plain text file exInvalidKey.php Class Class source
  Plain text file exUnknownData.php Class Class source

  Files folder image Files (26)  /  src  /  Exception  /  Storage  
File Role Description
  Plain text file exIOError.php Class Class source
  Plain text file exReadError.php Class Class source
  Plain text file exWriteError.php Class Class source

  Files folder image Files (26)  /  src  /  Http  
File Role Description
  Plain text file CookieStore.php Class Class source
  Plain text file SessionStore.php Class Class source

  Files folder image Files (26)  /  src  /  Interchange  
File Role Description
  Plain text file ExportInterchange.php Class Class source
  Plain text file JsonInterchange.php Class Class source
  Plain text file SerializeInterchange.php Class Class source

  Files folder image Files (26)  /  src  /  Interfaces  
File Role Description
  Plain text file iDataStore.php Class Class source
  Plain text file iInterchangeable.php Class Class source

  Files folder image Files (26)  /  src  /  Redis  
File Role Description
  Plain text file CleanScriptCommand.php Class Class source
  Plain text file CountScriptCommand.php Class Class source

  Files folder image Files (26)  /  src  /  Wrapper  
File Role Description
  Plain text file aWrapperDataStore.php Class Class source

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,503
This week:455Up