Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Nicolas Favre-Felix committed Nov 13, 2009
0 parents commit 637b1c4
Show file tree
Hide file tree
Showing 9 changed files with 2,520 additions and 0 deletions.
4 changes: 4 additions & 0 deletions CREDITS
@@ -0,0 +1,4 @@
Redis client extension for PHP
Alfonso Jimenez <yo@alfonsojimenez.com>
Nasreddine Bouafif <n.bouafif@owlient.eu>
Nicolas Favre-Felix <n.favre-felix@owlient.eu>
29 changes: 29 additions & 0 deletions README
@@ -0,0 +1,29 @@
============
= phpredis =
============

This is a fork of alfonsojimenez's phpredis.

This extension provides an API for communicating with Redis database, a persistent
key-value database with built-in net interface written in ANSI-C for Posix systems.

IMPORTANT
=========

This extension is experimental, it's still under development and it's not safe
enough for production use. The method names may change in future versions.


INSTALLING
==========

phpize
./configure
make && make install

CONTRIBUTING
============

Send comments, patches... to:
* n.bouafif@owlient.eu
* n.favre-felix@owlient.eu
50 changes: 50 additions & 0 deletions config.m4
@@ -0,0 +1,50 @@
dnl $Id$
dnl config.m4 for extension redis

PHP_ARG_ENABLE(redis, whether to enable redis support,
dnl Make sure that the comment is aligned:
[ --enable-redis Enable redis support])

if test "$PHP_REDIS" != "no"; then

dnl # --with-redis -> check with-path
dnl SEARCH_PATH="/usr/local /usr" # you might want to change this
dnl SEARCH_FOR="/include/redis.h" # you most likely want to change this
dnl if test -r $PHP_REDIS/$SEARCH_FOR; then # path given as parameter
dnl REDIS_DIR=$PHP_REDIS
dnl else # search default path list
dnl AC_MSG_CHECKING([for redis files in default path])
dnl for i in $SEARCH_PATH ; do
dnl if test -r $i/$SEARCH_FOR; then
dnl REDIS_DIR=$i
dnl AC_MSG_RESULT(found in $i)
dnl fi
dnl done
dnl fi
dnl
dnl if test -z "$REDIS_DIR"; then
dnl AC_MSG_RESULT([not found])
dnl AC_MSG_ERROR([Please reinstall the redis distribution])
dnl fi

dnl # --with-redis -> add include path
dnl PHP_ADD_INCLUDE($REDIS_DIR/include)

dnl # --with-redis -> check for lib and symbol presence
dnl LIBNAME=redis # you may want to change this
dnl LIBSYMBOL=redis # you most likely want to change this

dnl PHP_CHECK_LIBRARY($LIBNAME,$LIBSYMBOL,
dnl [
dnl PHP_ADD_LIBRARY_WITH_PATH($LIBNAME, $REDIS_DIR/lib, REDIS_SHARED_LIBADD)
dnl AC_DEFINE(HAVE_REDISLIB,1,[ ])
dnl ],[
dnl AC_MSG_ERROR([wrong redis lib version or lib not found])
dnl ],[
dnl -L$REDIS_DIR/lib -lm -ldl
dnl ])
dnl
dnl PHP_SUBST(REDIS_SHARED_LIBADD)

PHP_NEW_EXTENSION(redis, redis.c, $ext_shared)
fi
16 changes: 16 additions & 0 deletions debian.control
@@ -0,0 +1,16 @@
Package: phpredis
Version: 1.0
Section: web
Priority: optional
Architecture: all
Essential: no
Depends:
Pre-Depends:
Recommends: php5
Suggests:
Installed-Size:
Maintainer: Nicolas Favre-Felix [n.favre-felix@owlient.eu]
Conflicts:
Replaces:
Provides: phpredis
Description: Redis C extension for PHP5.
24 changes: 24 additions & 0 deletions mkdeb-apache2.sh
@@ -0,0 +1,24 @@
#!/bin/sh
phpize
./configure CFLAGS="-O3"
make clean all
DIR=`php-config5 --extension-dir | cut -c 2-`

rm -rf debian

mkdir -p debian
mkdir -p debian/DEBIAN
mkdir -p debian/$DIR

cp debian.control debian/DEBIAN/control

mkdir -p debian/etc/php5/apache2/conf.d/
mkdir -p debian/etc/php5/cli/conf.d/

echo "extension=redis.so" >> debian/etc/php5/apache2/conf.d/redis.ini

cp debian/etc/php5/apache2/conf.d/redis.ini debian/etc/php5/cli/conf.d/redis.ini

cp modules/redis.so debian/$DIR
dpkg -b debian phpredis-`uname -m`.deb
rm -rf debian/
118 changes: 118 additions & 0 deletions php_redis.h
@@ -0,0 +1,118 @@
/*
+----------------------------------------------------------------------+
| PHP Version 5 |
+----------------------------------------------------------------------+
| Copyright (c) 1997-2009 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| http://www.php.net/license/3_01.txt |
| If you did not receive a copy of the PHP license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@php.net so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
| Author: Alfonso Jimenez <yo@alfonsojimenez.com> |
+----------------------------------------------------------------------+
*/

#ifndef PHP_REDIS_H
#define PHP_REDIS_H

extern zend_module_entry redis_module_entry;

PHP_METHOD(Redis, __construct);
PHP_METHOD(Redis, connect);
PHP_METHOD(Redis, close);
PHP_METHOD(Redis, ping);
PHP_METHOD(Redis, get);
PHP_METHOD(Redis, set);
PHP_METHOD(Redis, add);
PHP_METHOD(Redis, getMultiple);
PHP_METHOD(Redis, exists);
PHP_METHOD(Redis, delete);
PHP_METHOD(Redis, incr);
PHP_METHOD(Redis, decr);
PHP_METHOD(Redis, type);
PHP_METHOD(Redis, getKeys);
PHP_METHOD(Redis, getSort);
PHP_METHOD(Redis, lPush);
PHP_METHOD(Redis, rPush);
PHP_METHOD(Redis, lPop);
PHP_METHOD(Redis, lSize);
PHP_METHOD(Redis, lRemove);
PHP_METHOD(Redis, listTrim);
PHP_METHOD(Redis, lGet);
PHP_METHOD(Redis, lGetRange);
PHP_METHOD(Redis, lSet);
PHP_METHOD(Redis, sAdd);
PHP_METHOD(Redis, sSize);
PHP_METHOD(Redis, sRemove);
PHP_METHOD(Redis, sContains);
PHP_METHOD(Redis, sGetMembers);
PHP_METHOD(Redis, setTimeout);

#ifdef PHP_WIN32
#define PHP_REDIS_API __declspec(dllexport)
#else
#define PHP_REDIS_API
#endif

#ifdef ZTS
#include "TSRM.h"
#endif

PHP_MINIT_FUNCTION(redis);
PHP_MSHUTDOWN_FUNCTION(redis);
PHP_RINIT_FUNCTION(redis);
PHP_RSHUTDOWN_FUNCTION(redis);
PHP_MINFO_FUNCTION(redis);

/* {{{ struct RedisSock */
typedef struct RedisSock_ {
php_stream *stream;
char *host;
unsigned short port;
long timeout;
int failed;
int status;
} RedisSock;
/* }}} */

#define redis_sock_name "Redis Socket Buffer"

#define REDIS_SOCK_STATUS_FAILED 0
#define REDIS_SOCK_STATUS_DISCONNECTED 1
#define REDIS_SOCK_STATUS_UNKNOWN 2
#define REDIS_SOCK_STATUS_CONNECTED 3

/* {{{ internal function protos */
PHPAPI RedisSock* redis_sock_create(char *host, int host_len, unsigned short port, long timeout);
PHPAPI int redis_sock_connect(RedisSock *redis_sock TSRMLS_DC);
PHPAPI int redis_sock_disconnect(RedisSock *redis_sock TSRMLS_DC);
PHPAPI int redis_sock_server_open(RedisSock *redis_sock, int TSRMLS_DC);
PHPAPI char * redis_sock_read(RedisSock *redis_sock, int *buf_len TSRMLS_DC);
PHPAPI char * redis_sock_read_bulk_reply(RedisSock *redis_sock, int bytes);
PHPAPI int redis_sock_read_multibulk_reply(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock, int *buf_len TSRMLS_DC);
PHPAPI int redis_sock_write(RedisSock *redis_sock, char *cmd, size_t sz);
PHPAPI void redis_free_socket(RedisSock *redis_sock);
/* }}} */

#ifdef ZTS
#define REDIS_G(v) TSRMG(redis_globals_id, zend_redis_globals *, v)
#else
#define REDIS_G(v) (redis_globals.v)
#endif

#define PHP_REDIS_VERSION "0.1.0"

#endif

/*
* Local variables:
* tab-width: 4
* c-basic-offset: 4
* End:
* vim600: noet sw=4 ts=4 fdm=marker
* vim<600: noet sw=4 ts=4
*/

0 comments on commit 637b1c4

Please sign in to comment.