承接 costalong/swoft-cache 相关项目开发

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

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

costalong/swoft-cache

Composer 安装命令:

composer require costalong/swoft-cache

包简介

swoft-cache component for swoft framework

README 文档

README

Swoft-cache component for swoft framework

Install

  • install by composer
composer require root/swoft-cache
  • update bean.php file
 Cache::MANAGER    => [
        'class'   => CacheManager::class,
        'adapter' => bean(Cache::ADAPTER),
        'lockAdapter' => Cache::LOCK
    ],
    Cache::ADAPTER    => [
        'class'        => RedisAdapter::class,
        'serializer'   => bean(Cache::SERIALIZER),
        'redis'        => bean('redis.pool'),
        "openListener" => true   // is open listener function  eg: false  setKey config invalid
        'setKey'       => \Costalong\Swoft\Cache\Handle\SetKeyListener\SetKeyLogs::class
    ],
    //cache原子锁配置
    Cache::LOCK => [
        'class' => RedisLock::class,
        'redis' => bean('redis.pool'),
        'prefix' => 'lock:'
    ],

    Cache::SERIALIZER => [
        'class' => PhpSerializer::class
    ],


    'redis'              => [
        'class'    => \Swoft\Redis\RedisDb::class,
        'host'     => '127.0.0.1',
        'port'     => 6379,
        'database' => 1,
        'option'   => [
            'prefix' => 'swoft:',
        ]
    ],
    'redis.pool' => [
        'class'       => Swoft\Redis\Pool::class,
        'redisDb'     => bean('redis'),
        'minActive'   => 10,
        'maxActive'   => 20,
        'maxWait'     => 0,
        'maxWaitTime' => 0,
        'maxIdleTime' => 60,
    ]
  • use example
  Cache::set("test",111,100);
  $data = Cache::get("test");



 if (Cache::lock('foo', 1000)->get()) {
  // 获取锁定10秒...
  Cache::lock('foo')->release();
}

 Cache::lock('foo', 10)->block(5, function () {
            // 等待最多5秒后获取锁定...
            return false;
});

 $value = Cache::remember('users', 30, function () {
      return 111;
 });

 //数据永久存储  需要调用delete清除
Cache::forever('key', 'value');

LICENSE

The Component is open-sourced software licensed under the Apache license.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: Apache-2.0
  • 更新时间: 2021-07-06

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固