sonata-project/cache 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

sonata-project/cache

最新稳定版本:2.2.0

Composer 安装命令:

composer require sonata-project/cache

包简介

Cache library

README 文档

README

Build Status

WARNING: This repository is deprecated

Cache is a small library to handle cache backend, the library also handle counter.

Installation using Composer

composer require sonata-project/cache

Cache Usage

<?php

use Sonata\Cache\Adapter\Cache\PRedisCache;

$adapter = new PRedisCache([
    'host'     => '127.0.0.1',
    'port'     => 6379,
    'database' => 42,
]);

$keys = [
    'objectId' => 10,
];

$adapter->set($keys, 'MyValue', 86400);

$cacheElement = $adapter->get($keys);

$cacheElement->getData(); // MyValue

Counter Usage

<?php

use Sonata\Cache\Adapter\Counter\PRedisCounter;

$adapter = new PRedisCounter([
    'host'     => '127.0.0.1',
    'port'     => 6379,
    'database' => 42,
]);


$counter = $adapter->increment('mystats');

// $counter is a Counter object
$counter->getValue(); // will return 1 if the counter is new

$counter = $adapter->increment($counter, 10);

$counter->getValue(); // will return 11

统计信息

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

GitHub 信息

  • Stars: 320
  • Watchers: 19
  • Forks: 30
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-01-04