承接 alb/phpketama 相关项目开发

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

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

alb/phpketama

最新稳定版本:v0.4.0

Composer 安装命令:

composer require alb/phpketama

包简介

README 文档

README

This is a pure-PHP implementation of libketama, a consistent hashing library.

Compatibility with libketama

PHP Ketama uses the same algorithm as libketama, and will always return the same results as libketama.

The API is not compatible.

Speed

Loading a cached continuum file is faster in PHP Ketama. Hashing is slower. As per the included benchmark, this makes PHP Ketama faster than libketama when doing up to 200 hashes per instance.

Usage

<?php

use Ketama\Ketama;
use Symfony\Component\Cache\Adapter\ApcuAdapter;
use Symfony\Component\Cache\Psr16Cache;

// Cache used to store the parsed continuum file
$cache = new Psr16Cache(new ApcuAdapter('mynamespace')

$ketama = new Ketama($cache);
$continuum = $ketama->createContinuum('/some/file');

// Lookup server
$ip = $continuum->getServer("some key");

Continuum file:

# server    weight
server1 1
server2 3
server3 1
server4 2

统计信息

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

GitHub 信息

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

其他信息

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