Download the PHP package mauretto78/in-memory-list without Composer
On this page you can find all versions of the php package mauretto78/in-memory-list. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download mauretto78/in-memory-list
More information about mauretto78/in-memory-list
Files in mauretto78/in-memory-list
Package in-memory-list
Short Description In Memory List
License MIT
Homepage https://github.com/mauretto78/in-memory-list
Informations about the package in-memory-list
In-memory List
In-memory List easily allows you to create and save your lists in memory.
If you are looking for a caching system for your lists this library is suitable for you.
Grab your lists from your API, your database or whatever you want and store them in memory: then, you can quickly retrieve your lists from cache, sorting and performing queries on them.
This package uses:
Basic Usage
To create and store in memory you list do the following:
Drivers
Avaliable drivers:
apcu
memcached
pdo
redis
(default driver)
Refer to official page for more details on PRedis connection.
Parameters
When use create
method to a generate a list, you can provide to it a parameters array. The allowed keys are:
uuid
- uuid of listelement-uuid
- uuid for the list elementsheaders
- headers array for the listchunk-size
- the chunks size in which the array will be splitted (integer) **ttl
- time to live of the list (in seconds) **
** = NOT AVALIABLE WITH PDO DRIVER
uuid
You can assign an uuid to your list (instead, a uuid will be generated):
headers
You can set a headers array to your list:
element-uuid
You can assign an uuid to list elemens (instead, a uuid will be generated). Consider this array:
Maybe you would use id
key as uuid in your list:
chunk-size
You can specify the number of elements of each chunk in which the original array will be splitted. The default value is 1000
.
PLEASE NOTE THAT chunk-size
IS NOT AVALIABLE WITH PDO DRIVER
ttl
You can specify a ttl (in seconds) for your lists:
PLEASE NOTE THAT ttl
IS NOT AVALIABLE WITH PDO DRIVER
Delete an element
To delete an element in you list do this:
Push an element
To push an element in you list, use pushElement
function. You must provide the list uuid, the element uuid and element data (data must be consistent - see Validation). Look at this example:
Update an element
To update an element in you list, use updateElement
function. You must provide the list uuid, the element uuid and element data (data must be consistent - see Validation). Look at this example:
Ttl
You can update ttl of a persisted list with updateTtl
method, and retrive the ttl with getTtl
function:
PLEASE NOTE THAT ttl
IS NOT AVALIABLE WITH PDO DRIVER
Validation (Data consistency)
Please note that your data must be consistent:
Instead, a ListElementNotConsistentException
will be thrown. Example:
Sorting and Quering
You can perform queries on your list. This library uses Array Query, please refer to it for the official documentation.
Commands
If you have an application which uses Symfony Console, you have some commands avaliable:
iml:cache:flush
to flush the cacheiml:cache:index [<from>] [<to>]
to get full index of items stored in cacheiml:cache:schema:create
Create database schema (only for PDO driver)iml:cache:schema:destroy
Destroys database schema (only for PDO driver)iml:cache:statistics
to get cache statistics
You can register the commands in your app, consider this example:
You have to provide to commands your driver and connection parameters array. Example:
Testing
In order to run all the tests, you have two options:
1. Install all the drivers on your machine
The first way it to install all the drivers on your machine:
- APCU - (install via PECL)
- MEMCACHED - (install via PECL)
- REDIS - (official install guide)
Once installed all the drivers, create a file called config/parameters.yml
and paste in the content of config/parameters.dist.yml
. Finally, change your configuration if needed:
2. Run the project with Docker
You can run the project with Docker.
STEP1: Make the build
STEP2: Raise the app
STEP3: Enter in the docker container
STEP4: Create the schema and run the tests in the container
Built With
- PRedis - Flexible and feature-complete Redis client for PHP and HHVM
- ramsey/uuid - A PHP 5.4+ library for generating RFC 4122 version 1, 3, 4, and 5 universally unique identifiers (UUID).
- Symfony Console - Symfony Console Component
Support
If you found an issue or had an idea please refer to this section.
Authors
- Mauro Cassani - github
License
This project is licensed under the MIT License - see the LICENSE.md file for details
All versions of in-memory-list with dependencies
ramsey/uuid Version ^3.6
symfony/console Version ^3.2|^4.0
symfony/yaml Version ^3.3|^4.0
doctrine/annotations Version 1.2.*
doctrine/instantiator Version 1.0.*
mauretto78/array-query Version ^1.0