Skip to content
This repository was archived by the owner on Aug 12, 2021. It is now read-only.

AEngine/orchid-memory

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Orchid Memory

Work with Key-Value storage by user-friendly interface.

Requirements

  • PHP >= 7.0

Supporting

  • Memcache
  • Redis

Installation

Run the following command in the root directory of your web project:

composer require aengine/orchid-memory

Usage

Connect to the server
Note: by default connect to Memcache

Mem::setup([
    [
        'host'    => 'localhost',
        'port'    => '11211',
        'timeout' => 10,
    ],
]);

Write data to storage

Mem::set('foo', 'bar');

Read data form storage

Mem::get('foo');

// -- or --

Mem::get('foo', function () {
    // some action, e.g. just return string
    return 'baz';
});

Get or Set Multiple (like a PSR-16)

// set rows
Mem::setMultiple([
    'cat:0' => 'Kiki',
    'cat:1' => 'Lucky',
    'dog:0' => 'Bucks',
    'cat:2' => 'Simon',
    'dog:1' => 'Eugene',
    'cat:3' => 'Rocky',
], 3600, 'animal');

// get data
$animals = Mem::getMultiple(['cat:0', 'cat:1', 'dog:0', 'cat:2', 'dog:1', 'cat:3']);

// remove data
Mem::deleteMultiple(['cat:0', 'cat:1', 'dog:0', 'cat:2', 'dog:1', 'cat:3']);

Tags

// set few rows
Mem::set('cat:0', 'Kiki', 3600, 'animal');
Mem::set('cat:1', 'Lucky', 3600, 'animal');
Mem::set('dog:0', 'Bucks', 3600, 'animal');
Mem::set('cat:2', 'Simon', 3600, 'animal');
Mem::set('dog:1', 'Eugene', 3600, 'animal');
Mem::set('cat:3', 'Rocky', 3600, 'animal');

// get data as array
$animal = Mem::getByTag('animal');

// remove data
Mem::deleteByTag('animal');

Contributing

Please see CONTRIBUTING for details.

License

The Orchid Memory is licensed under the MIT license. See License File for more information.

About

No description or website provided.

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages