定制 alksily/memory 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

alksily/memory

Composer 安装命令:

composer require alksily/memory

包简介

Memcache or Redis wrapper

README 文档

README

Work with Key-Value storage via user-friendly interface.

Requirements

  • PHP >= 7.0

Supporting

  • Memcache
  • Redis

Installation

Run the following command in the root directory of your web project:

composer require Alksily/memory

Usage

Connect to the server

Alksily\Memory\Mem::initialize([
    [
        'host'    => 'localhost',
        'port'    => '11211',
        'timeout' => 10,
        // additional can be passed options, server-role and pool name:
        // 'driver' => 'memcache', // or redis
    ]
]);

Write data to storage

Alksily\Memory\Mem::set('foo', 'bar');

Read data form storage

Alksily\Memory\Mem::get('foo', /* 'default value' */);

// -- or --

Alksily\Memory\Mem::get('foo', function () {
    // some action, e.g. just return string
    return 'baz';
});

Get or Set Multiple (like a PSR-16)

// set rows
Alksily\Memory\Mem::setMultiple([
    'cat:0' => 'Kiki',
    'cat:1' => 'Lucky',
    'dog:0' => 'Bucks',
    'cat:2' => 'Simon',
    'dog:1' => 'Eugene',
    'cat:3' => 'Rocky',
], 3600, 'animal');

// get data
$animals = Alksily\Memory\Mem::getMultiple(['cat:0', 'cat:1', 'dog:0', 'cat:2', 'dog:1', 'cat:3']);

// remove data
Alksily\Memory\Mem::deleteMultiple(['cat:0', 'cat:1', 'dog:0', 'cat:2', 'dog:1', 'cat:3']);

Tags

// set few rows
Alksily\Memory\Mem::set('cat:0', 'Kiki', 3600, 'animal');
Alksily\Memory\Mem::set('cat:1', 'Lucky', 3600, 'animal');
Alksily\Memory\Mem::set('dog:0', 'Bucks', 3600, 'animal');
Alksily\Memory\Mem::set('cat:2', 'Simon', 3600, 'animal');
Alksily\Memory\Mem::set('dog:1', 'Eugene', 3600, 'animal');
Alksily\Memory\Mem::set('cat:3', 'Rocky', 3600, 'animal');

// get data as array
$animal = Alksily\Memory\Mem::getByTag('animal');

// remove data
Alksily\Memory\Mem::deleteByTag('animal');

Contributing

Please see CONTRIBUTING for details.

License

The Alksily Memory is licensed under the MIT license. See License File for more information.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-10-10

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固