qmegas/memcache-search 问题修复 & 功能扩展

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

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

qmegas/memcache-search

最新稳定版本:0.1.3

Composer 安装命令:

composer require qmegas/memcache-search

包简介

PHP library to search memcache keys

README 文档

README

PHP library that allows to search keys in memcache. It uses lru_crawler non-blocking mechanism to iterate between memcache keys. This libary does not require memcache extension to be installed.

Why it's better then other solution?

  1. Standart Memcached extension have function getAllKeys which is based on memcached_dump function which is not guarentee to dump all keys. Also it reported that staring memcache 1.4.23 this function does not work.
  2. Standart Memcache extension does not have such functionallity and have different solutions based on stats cachedump which have memcache server performance impact and once again not guarentee to dump all keys.

Installation

composer require qmegas/memcache-search

Requirements

  • PHP >= 7.1
  • Memcache server should work on unix-like system and be >= 1.4.24

Usage Examples

<?php

$search = new \Qmegas\MemcacheSearch();
$search->addServer('127.0.0.1', 11211);

//Inline search in key name
$find = new \Qmegas\Finder\Inline('test');
foreach ($search->search($find) as $item) {
	echo "Key: {$item->getKey()} expires ".($item->getExpiration() === -1 ? 'NEVER' : 'on '.date('d/m/Y H:m:i', $item->getExpiration()))."\n";
}

//Inline search in key name - method 2
foreach ($search->search('test') as $item) {
	...
}

//Searching for non expiring items
$find = new \Qmegas\Finder\ExpiresNever();
foreach ($search->search($find) as $item) {
	...
}

//Searching in name by using regular expression
$find = new \Qmegas\Finder\RegExp('/Test([0-9]*)/i');
foreach ($search->search($find) as $item) {
	...
}

//Custom search logic
foreach ($search->search(function(\Qmegas\MemcacheItem $item): bool {
	//Your logic is here
}) as $item) {
	...
}

License

The library is open-sourced software licensed under the MIT license.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2020-06-24