承接 dcentrica/silverstripe-redis-cache 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

dcentrica/silverstripe-redis-cache

Composer 安装命令:

composer require dcentrica/silverstripe-redis-cache

包简介

Enables Redis cache for Silverstripe

README 文档

README

Enables usage of redis cache for Silverstripe.

status

Requirements

  • SilverStripe v4, v5, or v6
  • Redis/Valkey/DragonFly
  • Tested on PHP 7.3+

Pre-install

Ensure you have Redis or a Redis-like system installed in your environment and configured within your php ini files to ensure PHP knows where to find it.

To install Redis, a quick Google with your OS name and version, your PHP version, and server and the version that your're working with (E.G. Apache or Nginx) should yield a number of installation instructions such as this installation instruction example.

Add the following to your php.ini or conf.d/{your-custom-php-config-file}.ini to let PHP know where to communicate with Redis to store session data: Note: Missing this step will lead to login issues when working with providers such as AWS where you have your site running on multiple pods but need sessions to be unified across them.

session.save_handler  = redis
session.save_path     = {your_redis_url}

In containerised environments, the Redis PHP extensions which is available from Pecl.

Installation and usage

Use composer to pull this module into your project:

  $ composer require dcentrica/silverstripe-redis-cache

To enable Redis cache in your Silverstripe project, add one or both of the following yaml configs to your project under /app/_config/ in either their own yaml file, or in an existing file such as app.yml.

Note: The REDIS_URL must be the url of the used redis instance, e.g. tcp://127.0.0.1:6379.

Usage in your project

---
Name: silverstripe-redis-cache
After:
  - '#corecache'
  - '#assetscache'
Only:
  envvarset: REDIS_URL
---
SilverStripe\Core\Injector\Injector:
  # Redis PHP client
  RedisClient:
    class: Predis\Client
    constructor:
      0: '`MP_REDIS_HOST`'
  # Silverstripe Redis backend
  RedisCacheFactory:
    class: Zeitpulse\RedisCacheFactory
    constructor:
      client: '%$RedisClient'
  SilverStripe\Core\Cache\CacheFactory: '%$RedisCacheFactory'

  # Service-specific cache segements
  Psr\SimpleCache\CacheInterface.DMService_APICache:
    factory: RedisCacheFactory

  # vendor/silverstripe/assets/_config/assetscache.yml
  Psr\SimpleCache\CacheInterface.InterventionBackend_Manipulations:
    factory: RedisCacheFactory
    constructor:
      namespace: 'InterventionBackend_Manipulations'
      defaultLifetime: 600 # 10 mins

  Psr\SimpleCache\CacheInterface.FileShortcodeProvider:
    factory: RedisCacheFactory
    constructor:
      namespace: 'FileShortcodeProvider'
      defaultLifetime: 600 # 10 mins

Usage with flysystem asset storage

---
Name: silverstripes3-flysystem-redis
Only:
  envvarset:
    - REDIS_URL
After:
  - '#silverstripes3-flysystem'
---
SilverStripe\Core\Injector\Injector:
  League\Flysystem\Cached\Storage\Memory.public:
    class: League\Flysystem\Cached\Storage\Predis
  League\Flysystem\Cached\Storage\Adapter.public:
    class: League\Flysystem\Cached\Storage\Predis
  League\Flysystem\Cached\Storage\Adapter.protected:
    class: League\Flysystem\Cached\Storage\Predis

Licence

BSD-3

Credits

Authors:

统计信息

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

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 7
  • 开发语言: PHP

其他信息

  • 授权协议: BSD-3-Clause
  • 更新时间: 2026-04-20

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固