Skip to content

Commit 637b1c4

Browse files
author
Nicolas Favre-Felix
committed
Initial commit
0 parents  commit 637b1c4

9 files changed

+2520
-0
lines changed

CREDITS

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Redis client extension for PHP
2+
Alfonso Jimenez <[email protected]>
3+
Nasreddine Bouafif <[email protected]>
4+
Nicolas Favre-Felix <[email protected]>

README

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
============
2+
= phpredis =
3+
============
4+
5+
This is a fork of alfonsojimenez's phpredis.
6+
7+
This extension provides an API for communicating with Redis database, a persistent
8+
key-value database with built-in net interface written in ANSI-C for Posix systems.
9+
10+
IMPORTANT
11+
=========
12+
13+
This extension is experimental, it's still under development and it's not safe
14+
enough for production use. The method names may change in future versions.
15+
16+
17+
INSTALLING
18+
==========
19+
20+
phpize
21+
./configure
22+
make && make install
23+
24+
CONTRIBUTING
25+
============
26+
27+
Send comments, patches... to:
28+
29+

config.m4

+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
dnl $Id$
2+
dnl config.m4 for extension redis
3+
4+
PHP_ARG_ENABLE(redis, whether to enable redis support,
5+
dnl Make sure that the comment is aligned:
6+
[ --enable-redis Enable redis support])
7+
8+
if test "$PHP_REDIS" != "no"; then
9+
10+
dnl # --with-redis -> check with-path
11+
dnl SEARCH_PATH="/usr/local /usr" # you might want to change this
12+
dnl SEARCH_FOR="/include/redis.h" # you most likely want to change this
13+
dnl if test -r $PHP_REDIS/$SEARCH_FOR; then # path given as parameter
14+
dnl REDIS_DIR=$PHP_REDIS
15+
dnl else # search default path list
16+
dnl AC_MSG_CHECKING([for redis files in default path])
17+
dnl for i in $SEARCH_PATH ; do
18+
dnl if test -r $i/$SEARCH_FOR; then
19+
dnl REDIS_DIR=$i
20+
dnl AC_MSG_RESULT(found in $i)
21+
dnl fi
22+
dnl done
23+
dnl fi
24+
dnl
25+
dnl if test -z "$REDIS_DIR"; then
26+
dnl AC_MSG_RESULT([not found])
27+
dnl AC_MSG_ERROR([Please reinstall the redis distribution])
28+
dnl fi
29+
30+
dnl # --with-redis -> add include path
31+
dnl PHP_ADD_INCLUDE($REDIS_DIR/include)
32+
33+
dnl # --with-redis -> check for lib and symbol presence
34+
dnl LIBNAME=redis # you may want to change this
35+
dnl LIBSYMBOL=redis # you most likely want to change this
36+
37+
dnl PHP_CHECK_LIBRARY($LIBNAME,$LIBSYMBOL,
38+
dnl [
39+
dnl PHP_ADD_LIBRARY_WITH_PATH($LIBNAME, $REDIS_DIR/lib, REDIS_SHARED_LIBADD)
40+
dnl AC_DEFINE(HAVE_REDISLIB,1,[ ])
41+
dnl ],[
42+
dnl AC_MSG_ERROR([wrong redis lib version or lib not found])
43+
dnl ],[
44+
dnl -L$REDIS_DIR/lib -lm -ldl
45+
dnl ])
46+
dnl
47+
dnl PHP_SUBST(REDIS_SHARED_LIBADD)
48+
49+
PHP_NEW_EXTENSION(redis, redis.c, $ext_shared)
50+
fi

debian.control

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
Package: phpredis
2+
Version: 1.0
3+
Section: web
4+
Priority: optional
5+
Architecture: all
6+
Essential: no
7+
Depends:
8+
Pre-Depends:
9+
Recommends: php5
10+
Suggests:
11+
Installed-Size:
12+
Maintainer: Nicolas Favre-Felix [[email protected]]
13+
Conflicts:
14+
Replaces:
15+
Provides: phpredis
16+
Description: Redis C extension for PHP5.

mkdeb-apache2.sh

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/bin/sh
2+
phpize
3+
./configure CFLAGS="-O3"
4+
make clean all
5+
DIR=`php-config5 --extension-dir | cut -c 2-`
6+
7+
rm -rf debian
8+
9+
mkdir -p debian
10+
mkdir -p debian/DEBIAN
11+
mkdir -p debian/$DIR
12+
13+
cp debian.control debian/DEBIAN/control
14+
15+
mkdir -p debian/etc/php5/apache2/conf.d/
16+
mkdir -p debian/etc/php5/cli/conf.d/
17+
18+
echo "extension=redis.so" >> debian/etc/php5/apache2/conf.d/redis.ini
19+
20+
cp debian/etc/php5/apache2/conf.d/redis.ini debian/etc/php5/cli/conf.d/redis.ini
21+
22+
cp modules/redis.so debian/$DIR
23+
dpkg -b debian phpredis-`uname -m`.deb
24+
rm -rf debian/

php_redis.h

+118
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
/*
2+
+----------------------------------------------------------------------+
3+
| PHP Version 5 |
4+
+----------------------------------------------------------------------+
5+
| Copyright (c) 1997-2009 The PHP Group |
6+
+----------------------------------------------------------------------+
7+
| This source file is subject to version 3.01 of the PHP license, |
8+
| that is bundled with this package in the file LICENSE, and is |
9+
| available through the world-wide-web at the following url: |
10+
| http://www.php.net/license/3_01.txt |
11+
| If you did not receive a copy of the PHP license and are unable to |
12+
| obtain it through the world-wide-web, please send a note to |
13+
| [email protected] so we can mail you a copy immediately. |
14+
+----------------------------------------------------------------------+
15+
| Author: Alfonso Jimenez <[email protected]> |
16+
+----------------------------------------------------------------------+
17+
*/
18+
19+
#ifndef PHP_REDIS_H
20+
#define PHP_REDIS_H
21+
22+
extern zend_module_entry redis_module_entry;
23+
24+
PHP_METHOD(Redis, __construct);
25+
PHP_METHOD(Redis, connect);
26+
PHP_METHOD(Redis, close);
27+
PHP_METHOD(Redis, ping);
28+
PHP_METHOD(Redis, get);
29+
PHP_METHOD(Redis, set);
30+
PHP_METHOD(Redis, add);
31+
PHP_METHOD(Redis, getMultiple);
32+
PHP_METHOD(Redis, exists);
33+
PHP_METHOD(Redis, delete);
34+
PHP_METHOD(Redis, incr);
35+
PHP_METHOD(Redis, decr);
36+
PHP_METHOD(Redis, type);
37+
PHP_METHOD(Redis, getKeys);
38+
PHP_METHOD(Redis, getSort);
39+
PHP_METHOD(Redis, lPush);
40+
PHP_METHOD(Redis, rPush);
41+
PHP_METHOD(Redis, lPop);
42+
PHP_METHOD(Redis, lSize);
43+
PHP_METHOD(Redis, lRemove);
44+
PHP_METHOD(Redis, listTrim);
45+
PHP_METHOD(Redis, lGet);
46+
PHP_METHOD(Redis, lGetRange);
47+
PHP_METHOD(Redis, lSet);
48+
PHP_METHOD(Redis, sAdd);
49+
PHP_METHOD(Redis, sSize);
50+
PHP_METHOD(Redis, sRemove);
51+
PHP_METHOD(Redis, sContains);
52+
PHP_METHOD(Redis, sGetMembers);
53+
PHP_METHOD(Redis, setTimeout);
54+
55+
#ifdef PHP_WIN32
56+
#define PHP_REDIS_API __declspec(dllexport)
57+
#else
58+
#define PHP_REDIS_API
59+
#endif
60+
61+
#ifdef ZTS
62+
#include "TSRM.h"
63+
#endif
64+
65+
PHP_MINIT_FUNCTION(redis);
66+
PHP_MSHUTDOWN_FUNCTION(redis);
67+
PHP_RINIT_FUNCTION(redis);
68+
PHP_RSHUTDOWN_FUNCTION(redis);
69+
PHP_MINFO_FUNCTION(redis);
70+
71+
/* {{{ struct RedisSock */
72+
typedef struct RedisSock_ {
73+
php_stream *stream;
74+
char *host;
75+
unsigned short port;
76+
long timeout;
77+
int failed;
78+
int status;
79+
} RedisSock;
80+
/* }}} */
81+
82+
#define redis_sock_name "Redis Socket Buffer"
83+
84+
#define REDIS_SOCK_STATUS_FAILED 0
85+
#define REDIS_SOCK_STATUS_DISCONNECTED 1
86+
#define REDIS_SOCK_STATUS_UNKNOWN 2
87+
#define REDIS_SOCK_STATUS_CONNECTED 3
88+
89+
/* {{{ internal function protos */
90+
PHPAPI RedisSock* redis_sock_create(char *host, int host_len, unsigned short port, long timeout);
91+
PHPAPI int redis_sock_connect(RedisSock *redis_sock TSRMLS_DC);
92+
PHPAPI int redis_sock_disconnect(RedisSock *redis_sock TSRMLS_DC);
93+
PHPAPI int redis_sock_server_open(RedisSock *redis_sock, int TSRMLS_DC);
94+
PHPAPI char * redis_sock_read(RedisSock *redis_sock, int *buf_len TSRMLS_DC);
95+
PHPAPI char * redis_sock_read_bulk_reply(RedisSock *redis_sock, int bytes);
96+
PHPAPI int redis_sock_read_multibulk_reply(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock, int *buf_len TSRMLS_DC);
97+
PHPAPI int redis_sock_write(RedisSock *redis_sock, char *cmd, size_t sz);
98+
PHPAPI void redis_free_socket(RedisSock *redis_sock);
99+
/* }}} */
100+
101+
#ifdef ZTS
102+
#define REDIS_G(v) TSRMG(redis_globals_id, zend_redis_globals *, v)
103+
#else
104+
#define REDIS_G(v) (redis_globals.v)
105+
#endif
106+
107+
#define PHP_REDIS_VERSION "0.1.0"
108+
109+
#endif
110+
111+
/*
112+
* Local variables:
113+
* tab-width: 4
114+
* c-basic-offset: 4
115+
* End:
116+
* vim600: noet sw=4 ts=4 fdm=marker
117+
* vim<600: noet sw=4 ts=4
118+
*/

0 commit comments

Comments
 (0)