adammbalogh/key-value-store 问题修复 & 功能扩展

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

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

adammbalogh/key-value-store

Composer 安装命令:

composer require adammbalogh/key-value-store

包简介

Key-value store generic package. It contains abstractions.

README 文档

README

#Key Value Store

Author Build Status Coverage Status Quality Score Software License Packagist Version Total Downloads

SensioLabsInsight

Key Value Store is a library which abstracts the most used key value stores, like Redis or Memcached.

Description

This library provides an abstraction layer for key value stores. It is literally an abstraction because it contains only contracts and fundemantal implementations. So you need to install a store specific implementation a.k.a. an adapter.

Adapters

These are separate repositories!

Adapter name Repository
Memory key-value-store-memory
Shared Memory key-value-store-shared-memory
File key-value-store-file
Memcache key-value-store-memcache
Memcached key-value-store-memcached
Redis key-value-store-redis
Replicator key-value-store-replicator
Null key-value-store-null

Planned adapters

  • Apc
  • Couchbase
  • ?

Installation

This is an abstract package not a store specific implementation.

Please visit the links in the Adapters section.

Usage

with Redis (through predis/predis)

<?php
use AdammBalogh\KeyValueStore\KeyValueStore;
use AdammBalogh\KeyValueStore\Adapter\RedisAdapter as Adapter;
use Predis\Client as RedisClient;

$redisClient = new RedisClient();

$adapter = new Adapter($redisClient);

$kvs = new KeyValueStore($adapter);

$kvs->set('sample_key', 'Sample value');
$kvs->get('sample_key');
$kvs->delete('sample_key');

To see other specific examples please visit the links in the Adapters section.

API

You can call all of the API methods on a instance of KeyValueStore.

Key

/**
 * Removes a key.
 *
 * @param string $key
 *
 * @return bool True if the deletion was successful, false if the deletion was unsuccessful.
 *
 * @throws \InvalidArgumentException
 * @throws InternalException
 */
public function delete($key);

/**
 * Sets a key's time to live in seconds.
 *
 * @param string $key
 * @param int $seconds
 *
 * @return bool True if the timeout was set, false if the timeout could not be set.
 *
 * @throws \InvalidArgumentException
 * @throws InternalException
 */
public function expire($key, $seconds);

/**
 * Returns the remaining time to live of a key that has a timeout.
 *
 * @param string $key
 *
 * @return int Ttl in seconds.
 *
 * @throws \InvalidArgumentException
 * @throws KeyNotFoundException
 * @throws InternalException
 */
public function getTtl($key);

/**
 * Determines if a key exists.
 *
 * @param string $key
 *
 * @return bool True if the key does exist, false if the key does not exist.
 *
 * @throws \InvalidArgumentException
 * @throws InternalException
 */
public function has($key);

/**
 * Removes the existing timeout on key, turning the key from volatile (a key with an expire set)
 * to persistent (a key that will never expire as no timeout is associated).
 *
 * @param string $key
 *
 * @return bool True if the persist was success, false if the persis was unsuccessful.
 *
 * @throws \InvalidArgumentException
 * @throws InternalException
 */
public function persist($key);

Value

/**
 * Gets the value of a key.
 *
 * @param string $key
 *
 * @return mixed The value of the key.
 *
 * @throws \InvalidArgumentException
 * @throws KeyNotFoundException
 * @throws InternalException
 */
public function get($key);

/**
 * Sets the value of a key.
 *
 * @param string $key
 * @param mixed $value Can be any of serializable data type.
 *
 * @return bool True if the set was successful, false if it was unsuccessful.
 *
 * @throws \InvalidArgumentException
 * @throws InternalException
 */
public function set($key, $value);

Server

/**
 * Removes all keys.
 *
 * @return void
 *
 * @throws \AdammBalogh\KeyValueStore\Exception\InternalException
 */
public function flush();

Support

Support with Gittip

adammbalogh/key-value-store 适用场景与选型建议

adammbalogh/key-value-store 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 44.41k 次下载、GitHub Stars 达 49, 最近一次更新时间为 2014 年 09 月 22 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「nosql」 「store」 「value」 「key」 「key-value」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

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

围绕 adammbalogh/key-value-store 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

  • 总下载量: 44.41k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 49
  • 点击次数: 23
  • 依赖项目数: 12
  • 推荐数: 0

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2014-09-22