ryuske/redismodel

Use Redis as a primary data store.

v0.5 2016-08-03 08:25 UTC

This package is not auto-updated.

Last update: 2024-11-23 19:26:47 UTC


README

Latest Version on Packagist Software License Build Status Total Downloads

A Model accessor that makes using Redis as a primary data store easy.

Install

Via Composer

$ composer require Ryuske/RedisModel

Usage

/**
 * Available Methods:
 * get($id, $fields='all')
 *
 * searchBy($data, $fields='all');
 * searchByWildcard($data, $fields='all');
 * 
 * update($id)
 * save()
 *
 * delete($id)
 * delete()
 */

class Account extends Ryuske\Redis\Model
{
    /**
     * These are fields that are searchable.
     * The order of this list matters!
     * Add additional indexes to the bottom
     *
     * @var array
     */
    protected $indexes = [
        'id',
        'email'
    ];

    /**
     * These are additional, non-searchable indexes.
     * The order of this list doesn't matter.
     *
     * @var array
     */
    protected $fields = [
        'name',
        'password'
    ];
}

class MyController
{
    /**
     * @var Account
     */
    protected $account;

    public function __construct(Account $account)
    {
        $this->account = $account;
    }
    
    public function showAccount($id)
    {
        $account = $this->account->get($id);
        
        return view('account.show', [
            'account' => $account
        ]);
    }
}

Change log

Please see CHANGELOG for more information what has changed recently.

Testing

$ composer test

Security

If you discover any security related issues, please email kenyon.jh@gmail.com instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.