• Stars
    star
    155
  • Rank 240,864 (Top 5 %)
  • Language
    PHP
  • License
    ISC License
  • Created over 15 years ago
  • Updated over 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

a no-nonsense Redis client for PHP

Redisent

Redisent is a simple, no-nonsense interface to the Redis data structure store for modest developers. It is designed to flexible and tolerant of changes to the Redis protocol.

Introduction

If you're at all familiar with the Redis protocol and PHP objects, you've already mastered Redisent. Redisent translates method calls to their Redis protocol equivalent, abstracting away the nitty-gritty, and then makes the return values PHP compatible.

Features

Shared Redis API

The Redisent method names map directly to their Redis command counterparts. The full list is available in the command reference.

Setting Keys

$redis->set('foo', 'bar')
// SET foo bar

Working with lists

$redis->lpush('particles', 'electron')
// LPUSH particles electron
$redis->lpush('particles', 'proton')
// LPUSH particles proton
$redis->lpush('particles', 'neutron')
// LPUSH particles neutron
$redis->llen('particles')
// LLEN particles

Pipelining

Redisent provides a fluent interface for pipelining commands to Redis.

$redis->pipeline()
  ->set('X', 2)
  ->incr('X')
  ->incr('X')
  ->uncork(); // #=> array containing the responses of each command

Quick Start

Redisent has no dependencies aside from requiring PHP versions 5.3 and later. To add it to your project, simply drop the Redis.php file into your project structure, instantiate a Redis instance, and start issuing commands.

require_once 'redisent/Redis.php';
$redis = new redisent\Redis('redis://localhost');
$redis->set('awesome', 'absolutely');
echo "Is Redisent awesome? ", $redis->get('awesome'), "\n";

Any errors originating from Redis will be wrapped in a resident\RedisException and thrown.

Pipelining

Redisent supports a fluent interface for pipelining. A pipeline is started by calling the pipeline method on a Redis instance, using Redisent as usual, and then calling the uncork method. The uncork method returns an array of the responses of the pipelined commands.

Example

$redis = new redisent\Redis();
$responses = $redis->pipeline()
    ->incr('X')
    ->incr('X')
    ->incr('X')
    ->incr('X')
    ->uncork();
print_r($responses);

If the key X didn't exist, the first INCR would create it and return 1, and successive calls would increment it by 1. The return value of the call to uncork() would be array(1,2,3,4), the responses of each INCR command.

Contributing

Pull requests please! Feature/topic branches are especially appreciated. Unit tests are written with SimpleTest, please include tests in your pull request. To run tests, run sh setup.sh script to get set up and then php tests/all_tests.php to run the suite.

Roadmap

Redis has grown to be very feature rich, and Redisent is lagging behind.

  • Publish/subscribe
  • Transactions

About

Copyright Β© 2009-2012 Justin Poliey

License

Licensed under the ISC License.

Copyright (c) 2009-2012 Justin Poliey [email protected]

Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.

THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

Bitdeli Badge

More Repositories

1

twitterlibphp

An object-oriented PHP interface to the Twitter API
PHP
155
star
2

taxon

Organize and query data in Redis by tag
Python
60
star
3

jarg

shorthand JSON and form encoding syntax in the shell
Python
53
star
4

lineup

A minimalistic message queue server, in Go
PHP
32
star
5

tessera

A small PHP framework inspired by Juno, Sinatra, web.py, etc...
PHP
28
star
6

tarn

A completely Lua-scriptable roguelike engine
Lua
18
star
7

io-scgi

An implementation of SCGI for the Io programming language
Io
14
star
8

boid

Environment and package manager for Io
Io
13
star
9

concom

explore concatenative combinators
C
12
star
10

rosalind

solutions for problems at http://rosalind.info/
Python
12
star
11

gopher-server

A gopher protocol server
Go
10
star
12

hardbound

A static blog generator written in shell script
Shell
8
star
13

compoze

compoze aims to be a small, embeddable concatenative language
C
8
star
14

gluestick

A simple implementation of the Glue API in Ruby and PHP
Ruby
8
star
15

imgur

Interface gem for the Imgur API
Ruby
7
star
16

urp

a tool for extracting and modifying URL features
Python
6
star
17

hyperion

Organize Redis data as graphs
Python
6
star
18

biild

A tiny Ioke build system
6
star
19

euler

Project Euler solutions in different languages
Python
5
star
20

mdlisten

Like mdfind -live, but useful
Objective-C
4
star
21

tm2ta

A tool to help convert TextMate themes to TextAdept
PHP
3
star
22

emul8r

A chip-8 emulator
C
3
star
23

purl

A tiny URL shortener written in Bash and powered by Redis
Shell
3
star
24

justinpoliey.com

my personal website
CSS
3
star
25

sticks

A PHP microframework
PHP
3
star
26

pin

Homoiconic concatenative language
C
3
star
27

ephemeron

where transient data makes itself useful
C
2
star
28

pleo-script

Lisp to JavaScript transpiler in CoffeeScript
CoffeeScript
2
star
29

pyrebase

Firebase API client for Python
Python
2
star
30

tickit

A super-simple time tracking app
JavaScript
1
star
31

psionrl

A roguelike game based around psionics
C
1
star
32

twist

read new tweets on the command line
Shell
1
star
33

pyrelite

generate sql strings from relational expressions
Python
1
star
34

sun-moon-stars-rain

a real-time forum built with http://pusherapp.com
JavaScript
1
star
35

mnrl

Roguelike game based around MND
Python
1
star