PHPackages                             qingbing/php-db-cache - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Caching](/categories/caching)
4. /
5. qingbing/php-db-cache

ActiveLibrary[Caching](/categories/caching)

qingbing/php-db-cache
=====================

database的缓存操作

1.0.1(6y ago)03MITPHP

Since Jun 26Pushed 6y agoCompare

[ Source](https://github.com/qingbing/php-db-cache)[ Packagist](https://packagist.org/packages/qingbing/php-db-cache)[ Docs](http://www.phpcorner.net)[ RSS](/packages/qingbing-php-db-cache/feed)WikiDiscussions master Synced 3d ago

READMEChangelogDependencies (4)Versions (2)Used By (0)

php-db-cache
============

[](#php-db-cache)

描述
--

[](#描述)

DbCache：database缓存的相关解析和操作，可以单独使用

注意事项
----

[](#注意事项)

- 组件继承自"qingbing/php-abstracts-store"
- 缓存的参数配置参考 qingbing/php-config 组件
- 将缓存的"isWorking"设置成false，则缓存获取始终为"$default"
- 缓存的键名支持 字符串、数字、数组等可序列化的变量
- 缓存的键值支持 字符串、数字、数组等可序列化的变量
- 缓存支持批量的设置、获取、删除操作

使用方法
----

[](#使用方法)

```
// 获取缓存实例
$cache = \Components\DbCache::getInstance('db-cache');

// ====== 普通用法 ======
$key = "name";
// 设置缓存
$status = $cache->set($key, "ss");
var_dump($status);
// 获取缓存
$name = $cache->get($key);
var_dump($name);
// 删除缓存
$status = $cache->delete($key);
var_dump($status);
// 判断换成是否存在
$status = $cache->has($key);
var_dump($status);

// ====== 批量用法 ======
// 批量设置缓存
$status = $cache->setMultiple([
    "name" => 'ss',
    "author" => [
        'qingbing',
        '10000',
    ],
]);
var_dump($status);
// 批量获取缓存
$values = $cache->getMultiple(["name", "author"]);
var_dump($values);
// 批量删除缓存
$status = $cache->deleteMultiple(["name", "author"]);
var_dump($status);

// ====== 键、值随意化 ======
$key = ["sex", "name"];
// 设置缓存
$status = $cache->set($key, ["女", ["xxx"]]);
var_dump($status);
// 获取缓存
$status = $cache->get($key);
var_dump($status);
// 删除缓存
$status = $cache->delete($key);
var_dump($status);

// ====== 清空缓存 ======
// 清空命名空间换成
$status = $cache->clear();
var_dump($status);
```

====== 异常代码集合 ======
--------------------

[](#-异常代码集合-)

异常代码格式：1019 - XXX - XX （组件编号 - 文件编号 - 代码内异常）

```
 - 101900101 : db-cache 定义的数据库驱动有误，必须继承"\Components\Db"

```

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity3

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity59

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

2515d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/9379d2ee4885074de75faa3fa12970614186826f762df3c4aa0905dc1ff3b513?d=identicon)[qingbing](/maintainers/qingbing)

---

Top Contributors

[![qingbing](https://avatars.githubusercontent.com/u/33932784?v=4)](https://github.com/qingbing "qingbing (3 commits)")

---

Tags

phpcachedbdb-cache

### Embed Badge

![Health badge](/badges/qingbing-php-db-cache/health.svg)

```
[![Health](https://phpackages.com/badges/qingbing-php-db-cache/health.svg)](https://phpackages.com/packages/qingbing-php-db-cache)
```

###  Alternatives

[awssat/laravel-visits

Laravel Redis visits counter for Eloquent models

975163.6k2](/packages/awssat-laravel-visits)[swayok/alternative-laravel-cache

Replacements for Laravel's redis and file cache stores that properly implement tagging idea. Powered by cache pool implementations provided by http://www.php-cache.com/

202541.1k6](/packages/swayok-alternative-laravel-cache)[eftec/cacheone

A Cache library with minimum dependency

103.5k4](/packages/eftec-cacheone)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
