ryuske/

redismodel

使用Redis作为主要数据存储。

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

This package is not auto-updated.

Last update: 2024-09-14 18:20:46 UTC


README

Latest Version on Packagist Software License Build Status Total Downloads

一个使使用Redis作为主要数据存储变得简单的模型访问器。

安装

通过Composer

$ composer require Ryuske/RedisModel

用法

/**
 * 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
        ]);
    }
}

变更日志

请参阅变更日志获取更多信息,了解最近有哪些更改。

测试

$ composer test

安全

如果您发现任何与安全相关的问题,请发送电子邮件至kenyon.jh@gmail.com,而不是使用问题跟踪器。

鸣谢

许可证

MIT许可证(MIT)。有关更多信息,请参阅许可证文件