定制 flashytime/db-cache 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

flashytime/db-cache

Composer 安装命令:

composer require flashytime/db-cache

包简介

A PHP library to cache database, supports MySQL,Mongo and Memcached,Redis...

README 文档

README

A PHP library to cache database query, supports MySQL/Mongo and Memcached/Redis...

中文版

Features

  • Supports common databases, such as MySQL、Mongo
  • Supports common cache servers, such as Memcached、Redis
  • Supports database master-slave and reading/writing separation
  • Supports MySQL database table sharding
  • Manage cache through a version strategy, which controls the creation and expiration of the cache

Installation

  • Run the command below in your project root directory
composer require flashytime/db-cache
  • Copy config/db-cache.php to your project config directory

Usage

class TestModel
{
    public $dbCache;

    public function __construct()
    {
        // you can get the config in your own way
        $config = $this->getConfig();
        $this->dbCache = new \Flashytime\DbCache\DbCache($config, 'Test', ['name' => 'test', 'primary' => 'id']);
    }

    public function create($data)
    {
        return $this->dbCache->insert($data);
    }

    public function getById($id)
    {
        return $this->dbCache->select(['where' => 'id = :id'], ['id' => $id]);
    }

    public function findAll($offset, $limit)
    {
        return $this->dbCache->all(['limit' => ':offset, :limit', 'order' => 'id DESC'], ['offset' => $offset, 'limit' => $limit]);
    }

    public function updateById($id, $data)
    {
        return $this->dbCache->update(['where' => 'id = :id'], ['id' => $id], $data);
    }

    public function remove($id)
    {
        return $this->dbCache->delete(['where' => 'id = :id'], ['id' => $id]);
    }

    public function getConfig()
    {
        //path to your config directory
        return require __DIR__ . '/../config/db-cache.php';
    }
}

License

MIT

统计信息

  • 总下载量: 13
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2018-05-11

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固