PHP code example of nabeghe / mem

1. Go to this page and download the library: Download nabeghe/mem library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

nabeghe / mem example snippets


// Checks if a key exists in a cache group.
Mem::has(mixed $key, mixed $group = 'default'): bool

// Returns the first key of an item that matches the regex.
Mem::match($regex, $group = 'default'): ?string

// Returns items whose keys match the regex.
Mem::matches($regex, $group = 'default'): ?array

// Checks if a group exists.
Mem::hasGroup(mixed $group): bool

// Returns the value of a key from a group.
Mem::get(mixed $key, mixed $group = 'default', mixed $default = null): bool

// Changes the value of a key in a group.
Mem::set(mixed $key, mixed $value, mixed $group = 'default'): bool

// Deletes a key from a group.
Mem::del($key, $group = 'default'): bool

// Deletes items based on key matching with regex.
Mem::delMatches($regex, $group = 'default'): bool

// Returns all storages (groups) and their keys.
Mem::all(): array

// Returns all keys and values of a group.
Mem::group($group = 'default'): Storage

// Returns the number of existing groups.
Mem::groupsCount(): int

// Clears the entire group.
Mem::drop($group = 'default'): bool

// Clears the entire cache.
Mem::reset(): bool


Mem::config('default', ['length_limit' => 3]);

Mem::set('item_1', 'value 1');
Mem::set('item_2', 'value 2');
Mem::set('item_3', 'value 3');
Mem::set('item_4', 'value 4');

/*
 * Items in the default group:
 *  [
 *      'item_2' => 'value 2',
 *      'item_3' => 'value 3',
 *      'item_4' => 'value 4'
 *  ]
 */