earc/data-redis 问题修复 & 功能扩展

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

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

earc/data-redis

Composer 安装命令:

composer require earc/data-redis

包简介

eArc - the explicit architecture framework - data redis component

README 文档

README

Redis bridge providing entity-caching for the earc/data abstraction.

installation

Install the earc/data-redis library via composer.

$ composer require earc/data-redis

basic usage

Initialize the earc/data abstraction in your index.php, bootstrap or configuration script.

use eArc\Data\Initializer;

Initializer::init();

Then register the earc/data-redis bridge to the earc/data onLoad, onPersit and onRemove events.

use eArc\Data\ParameterInterface;
use eArc\DataRedis\RedisDataBridge;

// The order of the on load tagging is important!
di_tag(ParameterInterface::TAG_ON_LOAD, RedisDataBridge::class);
di_tag(ParameterInterface::TAG_ON_LOAD, MyDatabaseBridge::class);

di_tag(ParameterInterface::TAG_ON_PERSIST, RedisDataBridge::class);
di_tag(ParameterInterface::TAG_ON_PERSIST, MyDatabaseBridge::class);

di_tag(ParameterInterface::TAG_ON_REMOVE, RedisDataBridge::class);
di_tag(ParameterInterface::TAG_ON_REMOVE, MyDatabaseBridge::class);

Important: For the onLoad event you have to tag the RedisDataBridge before your database bridge. Otherwise, the entities will never be loaded from cache.

Now earc/data uses your redis server to cache your entities.

connection parameter for redis

By default, earc/data-redis uses localhost and the defaults of the php-redis-extension. You can overwrite these defaults:

use eArc\DataRedis\ParameterInterface;

di_set_param(ParameterInterface::REDIS_CONNECTION, ['127.0.0.1', 6379]);

This array is handed to the Redis::connect() method as arguments. Consult the phpredis documentation for valid values and configuration options.

advanced usage

earc/data-redis uses redis hashes to cache your entities. By default, the hash-keys are prefixed by earc-data. If you need another prefix to manage the redis namespace, you can overwrite the default:

use eArc\DataRedis\ParameterInterface;

di_set_param(ParameterInterface::HASH_KEY_PREFIX, 'some-hash-key-prefix');

releases

release 0.0

  • the first official release
  • PHP ^8.0
  • Redis >=4.0.0

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2021-04-03

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固