Coder Social home page Coder Social logo

php-redis-implementation's Introduction

PHP Redis implementation V2.1

Yet another php redis implementation. Raw wrapper for real Redis fans. Main advantages:

  • Doesn't require any dependencies as all the communication goes via tcp socket.
  • All commands are passed as is, so you have all the freedom to play with redis just like in redis-cli.
  • It won't get deprecated or obsolete for the same reason. You write raw commands by yourself.
  • Doesn't matter which redis version you have.
  • Supports chainable methods. Write multiple commands and send everything at once.
  • Custom error function to handle errors.
  • Dead Simple and lightweight, you're welcome to read all the 300+ lines of redis.php
  • Forces you to actually learn and understand redis data structures and commands.

Download

You can checkout latest version with:

$ git clone git://github.com/ziogas/PHP-Redis-implementation

Install

To install PHP redis:

  • Simply copy redis.php to your site and require it from external script

Here are some examples:

require 'redis.php';

function redis_error($error) {
    throw new error($error);
}

$redis = new redis_cli ();
$redis->set_error_function('redis_error');

$redis->cmd('SET', 'foo', 'bar')
      ->cmd('HSET', 'hash', 'field', 'val')
      ->cmd('EXPIRE', 'foo', 300)
      ->set();

$foo = $redis->cmd('GET', 'foo')->get();
$field = $redis->cmd('HGET', 'hash', 'field')->get();

var_dump($foo);
var_dump($field);

More usage examples can be found on tests folder. For commands documentation just go directly to https://redis.io/commands

Running tests

To run tests you'll need phpunit

Execute: phpunit tests/*

Contributing

  1. Fork it!
  2. Create your feature branch: git checkout -b my-new-feature
  3. Commit your changes: git commit -am 'Add some feature'
  4. Push to the branch: git push origin my-new-feature
  5. Submit a pull request

Author

Arminas Zukauskas - [email protected]

Based on http://redis.io/topics/protocol

License

MIT Do whatever you want, attribution is nice but not required

php-redis-implementation's People

Contributors

nate8nate avatar nicabashian avatar ziogas avatar

Watchers

 avatar  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.