rumd3x/php-persistence

Store and retrieve data without a database.

1.4.0 2018-12-20 03:05 UTC

This package is auto-updated.

Last update: 2024-04-20 16:47:17 UTC


README

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();