Skip to content

rumd3x/php-persistence

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

php-persistence

Store persistent data and retrieve it without a database.

Installation

To install via composer just run

  composer require rumd3x/php-persistence

Usage

Getting started

Create an instance of the Persistence Engine passing a string with the driver name. Every driver is a totally different database. If data is getting too hard to manage you should probably be using more drivers.

use Rumd3x\Persistence\Engine;
$driver = 'test-db';
$db = new Engine($driver);

Storing data

You can store an instance of any object, arrays of mixed data, strings, etc.

When you retrieve your data, you'll get back exactly what you've stored.

When your data is stored, it's being put at the bottom of a stack.

$array = ['hello' => 'world', 1234, 1.666];
$db->store($array);

Retrieving data

The engine uses FIFO.

So when you retrieve your data, you'll be retrieving from the top of the stack.

If the driver has nothing stored in it, it will return null

Also, when you retrieve your data, it will be erased from the stack, so if you are using it again, make sure to store it back.

$data = $db->retrieve();

About

Store and retrieve data without a database.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages