定制 tsk/simple-redis-dal 二次开发

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

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

tsk/simple-redis-dal

Composer 安装命令:

composer require tsk/simple-redis-dal

包简介

Simple Redis Abstraction

README 文档

README

Simple Redis Abstraction Layer

Installation with composer

Install library via composer

composer require tsk/simple-redis-dal

Initialization

Simple initialization

$db = new hooli("127.0.0.0", "password");

Check if eveything works

Simple check

$db->ping();

Handling simple values

Set a value

$key = "username";
$db->setvalue($key, "MaryPoppins");

Get the value

$username = $db->getvalue($key);

Delete a value

$key = "username";
$db->delete($key);

Cache a value

$key = "session_id";
$value = "12345";
$time = 20 // Time is in minutes

$db->cachevalue($key, $value, $time);

Expire a value

$key = "session_id";
$time = 1 // Time in minutes

$db->expire($key, $time);

Dealing with Hashes

Create a hash / Store data into a hash (record types structured as collections of field-value pairs)

$data = [
    "firstName" => "Mary",
    "lastName" => "Poppins",
    "email" => "marypoppins@email.com",
    "location" => "USA, New York"
];
$HashName = 'marypoppins@email.com';
$db->createhash($HashName, $data);

Check if a value exists in a hash

$HashName = 'marypoppins@email.com';
$db->checkhash($HashName, "firstName");

Update / replace a single value in a hash

$HashName = 'marypoppins@email.com';
$db->replacehash($HashName, "location", "Nigeria, Lagos");

Insert new value into hash

$HashName = 'marypoppins@email.com';
$db->inserthash($HashName, "age", 32);

Fetch all values in a single hash

$HashName = 'marypoppins@email.com';
$db->gethash($HashName);

or using return types
$db->json()->gethash($HashName);

Count the keys in a hash

$HashName = 'marypoppins@email.com';
$count = $db->countkeys($HashName);

Increase a value in a hash

$HashName = 'marypoppins@email.com';
$key = 'age'; // The value of this key must be an integer
$increaseBy = 4;
$db->increase($HashName, $key); // This method increases the value by one
$db->increaseby($HashName, $key, $increaseBy); // This method increases the value by the specified number 

Dealing with lists

Insert value into a list

$List = "users";
$db->insertlist($List, "something@email.com");

search for a value inside a list

$List = "users";
if($db->search_list($List, "something@email.com")){
    echo 'value exists';
}

Count number of values /entries in a List

$List = "users";
$db->countlist($List);

Delete a List

$List = "users";
$db->deletelist($List);

Return all values in a List as JSON return type

$List = "users";
$db->json()->getlist($List);

Get a specific number of elements from a list

$List = "users";
$num = 10;
$users = $db->getlistnum($List, $num); // Returns an array

Dealing with HashLists

Save hashes to list (HashList) while mapping each value in list to key in hash

$data = [
    "firstName" => "Mary",
    "lastName" => "Poppins",
    "email" => "marypoppins@email.com",
    "location" => "USA, New York"
];
$list = "users";
$userID = "mary123";
$db->inserthashlist($userID, $data, $list);

Return all data in a HashList as json

$list = "users";
echo $db->gethashlist($list);

fetching specified number of keys in a list

list Name of the Redis list num is asigned the number of keys to be fetched

echo $db->getlistnum($list, $num)

Fetching specified number of hashes

list Name of the Redis list num reperesents the number of hashes to fetch from a list

echo $db->gethashlistnum($list, $num)

Collaborators ✨

timek
Tim3k
kusaasira
Joshua Kusaasira
Marshud
Marshud

tsk/simple-redis-dal 适用场景与选型建议

tsk/simple-redis-dal 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 113 次下载、GitHub Stars 达 4, 最近一次更新时间为 2022 年 10 月 10 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 tsk/simple-redis-dal 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 tsk/simple-redis-dal 我们能提供哪些服务?
定制开发 / 二次开发

基于 tsk/simple-redis-dal 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

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

GitHub 信息

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

其他信息

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