Giter VIP home page Giter VIP logo

key-value-store's Introduction

#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 values 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.

Support

Support with Gittip

Adapters

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');

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

Installation

This is an abstract package not a speficic implementation.

Please visit the links in the Adapters section.

API

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);

/**
 * @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);

/**
 * @return array
 *
 * @throws InternalException
 */
public function getKeys();

/**
 * 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);

/**
 * @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);

/**
 * Remove 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);

String

/**
 * @param string $key
 * @param string $value
 *
 * @return int The length of the string after the append operation.
 *
 * @throws \InvalidArgumentException
 * @throws KeyNotFoundException
 * @throws InternalException
 */
public function append($key, $value);

/**
 * @param string $key
 *
 * @return int The value of key after the decrement
 *
 * @throws \InvalidArgumentException
 * @throws KeyNotFoundException
 * @throws InternalException
 */
public function decrement($key);

/**
 * @param string $key
 * @param int $decrement
 *
 * @return int The value of key after the decrement
 *
 * @throws \InvalidArgumentException
 * @throws KeyNotFoundException
 * @throws InternalException
 */
public function decrementBy($key, $decrement);

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

/**
 * @param string $key
 *
 * @return int
 *
 * @throws \InvalidArgumentException
 * @throws KeyNotFoundException
 * @throws InternalException
 */
public function getValueLength($key);

/**
 * @param string $key
 *
 * @return int The value of key after the increment
 *
 * @throws \InvalidArgumentException
 * @throws KeyNotFoundException
 * @throws InternalException
 */
public function increment($key);

/**
 * @param string $key
 * @param int $increment
 *
 * @return int The value of key after the increment
 *
 * @throws \InvalidArgumentException
 * @throws KeyNotFoundException
 * @throws InternalException
 */
public function incrementBy($key, $increment);

/**
 * @param string $key
 * @param string $value
 *
 * @return bool True if the set was successful, false if it was unsuccessful
 *
 * @throws \InvalidArgumentException
 * @throws InternalException
 */
public function set($key, $value);

/**
 * @param string $key
 * @param string $value
 *
 * @return bool True if the set was successful, false if it was unsuccessful
 *
 * @throws \InvalidArgumentException
 * @throws InternalException
 */
public function setIfNotExists($key, $value);

Server

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

key-value-store's People

Contributors

adammbalogh avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.