2017 © Pedro PelĂĄez
 

library db-cache

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

image

flashytime/db-cache

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

  • Friday, May 11, 2018
  • by flashytime
  • Repository
  • 1 Watchers
  • 1 Stars
  • 1 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

db-cache

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

䞭文版

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, (*2)

The Versions

11/05 2018

dev-master

9999999-dev

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

  Sources   Download

MIT

The Requires

  • php >=5.6

 

The Development Requires

by Avatar flashytime

11/05 2018

v1.0.0

1.0.0.0

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

  Sources   Download

MIT

The Requires

  • php >=5.6

 

The Development Requires

by Avatar flashytime