Skip to content
Browse files

Add libredis implementation

  • Loading branch information...
1 parent caa03d7 commit b7a2e4a9c3a6577928a06caab475eda3af37e6c3 @lcastelli committed with evoloshchuk
View
9 CMake/HPHPFindLibs.cmake
@@ -306,6 +306,13 @@ if (FREEBSD)
FIND_LIBRARY (EXECINFO_LIB execinfo)
endif()
+FIND_LIBRARY(LIBREDIS_LIB redis)
+FIND_PATH(LIBREDIS_INCLUDE_DIR libredis/redis.h)
+if (NOT LIBREDIS_LIB OR NOT LIBREDIS_INCLUDE_DIR)
+ message(FATAL_ERROR "libredis not found")
+endif()
+include_directories(${LIBREDIS_INCLUDE_DIR})
+
#find_package(BISON REQUIRED)
#find_package(FLEX REQUIRED)
@@ -398,4 +405,6 @@ endif()
target_link_libraries(${target} ${PAM_LIBRARY})
endif()
+ target_link_libraries(${target} ${LIBREDIS_LIB})
+
endmacro()
View
4 bin/license.php
@@ -29,6 +29,10 @@
'runtime/ext/ext_memcached.cpp' => 'hyves',
'test/test_ext_memcached.h' => 'hyves',
'test/test_ext_memcached.cpp' => 'hyves',
+ 'runtime/ext/ext_libredis.h' => 'hyves',
+ 'runtime/ext/ext_libredis.cpp' => 'hyves',
+ 'test/test_ext_libredis.h' => 'hyves',
+ 'test/test_ext_libredis.cpp' => 'hyves',
);
$files_zend = array(
View
640 src/idl/libredis.idl.php
@@ -0,0 +1,640 @@
+<?php
+/**
+ * Automatically generated by running "php schema.php libredis".
+ *
+ * You may modify the file, but re-running schema.php against this file will
+ * standardize the format without losing your schema changes. It does lose
+ * any changes that are not part of schema. Use "note" field to comment on
+ * schema itself, and "note" fields are not used in any code generation but
+ * only staying within this file.
+ *
+ * @nolint
+ */
+///////////////////////////////////////////////////////////////////////////////
+// Preamble: C++ code inserted at beginning of ext_{name}.h
+
+DefinePreamble(<<<CPP
+#include <libredis/redis.h>
+CPP
+);
+
+///////////////////////////////////////////////////////////////////////////////
+// Constants
+//
+// array (
+// 'name' => name of the constant
+// 'type' => type of the constant
+// 'note' => additional note about this constant's schema
+// )
+
+
+///////////////////////////////////////////////////////////////////////////////
+// Functions
+//
+// array (
+// 'name' => name of the function
+// 'desc' => description of the function's purpose
+// 'flags' => attributes of the function, see base.php for possible values
+// 'opt' => optimization callback function's name for compiler
+// 'note' => additional note about this function's schema
+// 'return' =>
+// array (
+// 'type' => return type, use Reference for ref return
+// 'desc' => description of the return value
+// )
+// 'args' => arguments
+// array (
+// 'name' => name of the argument
+// 'type' => type of the argument, use Reference for output parameter
+// 'value' => default value of the argument
+// 'desc' => description of the argument
+// )
+// )
+
+DefineFunction(
+ array(
+ 'name' => "libredis",
+ 'flags' => HasDocComment,
+ 'return' => array(
+ 'type' => Object,
+ ),
+ ));
+
+
+///////////////////////////////////////////////////////////////////////////////
+// Classes
+//
+// BeginClass
+// array (
+// 'name' => name of the class
+// 'desc' => description of the class's purpose
+// 'flags' => attributes of the class, see base.php for possible values
+// 'note' => additional note about this class's schema
+// 'parent' => parent class name, if any
+// 'ifaces' => array of interfaces tihs class implements
+// 'bases' => extra internal and special base classes this class requires
+// 'footer' => extra C++ inserted at end of class declaration
+// )
+//
+// DefineConstant(..)
+// DefineConstant(..)
+// ...
+// DefineFunction(..)
+// DefineFunction(..)
+// ...
+// DefineProperty
+// DefineProperty
+//
+// array (
+// 'name' => name of the property
+// 'type' => type of the property
+// 'flags' => attributes of the property
+// 'desc' => description of the property
+// 'note' => additional note about this property's schema
+// )
+//
+// EndClass()
+
+///////////////////////////////////////////////////////////////////////////////
+
+BeginClass(
+ array(
+ 'name' => "_Libredis_Ketama",
+ 'bases' => array('Sweepable'),
+ 'flags' => HasDocComment,
+ 'footer' => <<<EOT
+
+ public:
+ Ketama *getKetama();
+
+ private:
+ Ketama *m_ketama;
+EOT
+,
+ ));
+
+DefineFunction(
+ array(
+ 'name' => "__construct",
+ 'flags' => HasDocComment,
+ 'return' => array(
+ 'type' => null,
+ ),
+ ));
+
+DefineFunction(
+ array(
+ 'name' => "add_server",
+ 'flags' => HasDocComment,
+ 'return' => array(
+ 'type' => null,
+ ),
+ 'args' => array(
+ array(
+ 'name' => "host",
+ 'type' => String,
+ ),
+ array(
+ 'name' => "port",
+ 'type' => Int32,
+ ),
+ array(
+ 'name' => "weight",
+ 'type' => Int32,
+ ),
+ ),
+ ));
+
+DefineFunction(
+ array(
+ 'name' => "get_server_ordinal",
+ 'flags' => HasDocComment,
+ 'return' => array(
+ 'type' => Int32,
+ ),
+ 'args' => array(
+ array(
+ 'name' => "key",
+ 'type' => String,
+ ),
+ ),
+ ));
+
+DefineFunction(
+ array(
+ 'name' => "get_server_address",
+ 'flags' => HasDocComment,
+ 'return' => array(
+ 'type' => String,
+ ),
+ 'args' => array(
+ array(
+ 'name' => "ordinal",
+ 'type' => Int32,
+ ),
+ ),
+ ));
+
+DefineFunction(
+ array(
+ 'name' => "create_continuum",
+ 'flags' => HasDocComment,
+ 'return' => array(
+ 'type' => null,
+ ),
+ ));
+
+DefineFunction(
+ array(
+ 'name' => "__destruct",
+ 'flags' => HasDocComment,
+ 'return' => array(
+ 'type' => Variant,
+ ),
+ ));
+
+EndClass(
+);
+
+///////////////////////////////////////////////////////////////////////////////
+
+BeginClass(
+ array(
+ 'name' => "_Libredis_Executor",
+ 'bases' => array('Sweepable'),
+ 'flags' => HasDocComment,
+ 'footer' => <<<EOT
+
+ public:
+ Executor *getExecutor();
+
+ private:
+ Executor *m_executor;
+EOT
+,
+ ));
+
+DefineFunction(
+ array(
+ 'name' => "__construct",
+ 'flags' => HasDocComment,
+ 'return' => array(
+ 'type' => null,
+ ),
+ ));
+
+DefineFunction(
+ array(
+ 'name' => "add",
+ 'flags' => HasDocComment,
+ 'return' => array(
+ 'type' => Variant,
+ ),
+ 'args' => array(
+ array(
+ 'name' => "connection",
+ 'type' => Object,
+ ),
+ array(
+ 'name' => "batch",
+ 'type' => Object,
+ ),
+ ),
+ ));
+
+DefineFunction(
+ array(
+ 'name' => "execute",
+ 'flags' => HasDocComment,
+ 'return' => array(
+ 'type' => Variant,
+ ),
+ 'args' => array(
+ array(
+ 'name' => "timeout",
+ 'type' => Int32,
+ 'value' => "5000",
+ ),
+ ),
+ ));
+
+DefineFunction(
+ array(
+ 'name' => "__destruct",
+ 'flags' => HasDocComment,
+ 'return' => array(
+ 'type' => Variant,
+ ),
+ ));
+
+EndClass(
+);
+
+///////////////////////////////////////////////////////////////////////////////
+
+BeginClass(
+ array(
+ 'name' => "_Libredis_Connection",
+ 'bases' => array('Sweepable'),
+ 'flags' => HasDocComment,
+ 'footer' => <<<EOT
+
+ public:
+ Connection *getConnection();
+ bool executeSimple(Batch *batch, int timeout);
+
+ private:
+ class ConnectionWrapper {
+ public:
+ ConnectionWrapper(Connection *c);
+ ~ConnectionWrapper();
+ Connection *connection;
+ };
+ typedef boost::shared_ptr<ConnectionWrapper> ConnectionPtr;
+
+ ConnectionPtr m_connection;
+
+ typedef std::map<std::string, ConnectionPtr> ConnectionMap;
+ static DECLARE_THREAD_LOCAL(ConnectionMap, s_persistentMap);
+EOT
+,
+ ));
+
+DefineFunction(
+ array(
+ 'name' => "__construct",
+ 'flags' => HasDocComment,
+ 'return' => array(
+ 'type' => null,
+ ),
+ 'args' => array(
+ array(
+ 'name' => "address",
+ 'type' => String,
+ ),
+ ),
+ ));
+
+DefineFunction(
+ array(
+ 'name' => "execute",
+ 'flags' => HasDocComment,
+ 'return' => array(
+ 'type' => Boolean,
+ ),
+ 'args' => array(
+ array(
+ 'name' => "batch",
+ 'type' => Object,
+ ),
+ array(
+ 'name' => "timeout",
+ 'type' => Int32,
+ 'value' => "5000",
+ ),
+ ),
+ ));
+
+DefineFunction(
+ array(
+ 'name' => "set",
+ 'flags' => HasDocComment,
+ 'return' => array(
+ 'type' => Variant,
+ ),
+ 'args' => array(
+ array(
+ 'name' => "key",
+ 'type' => String,
+ ),
+ array(
+ 'name' => "value",
+ 'type' => String,
+ ),
+ array(
+ 'name' => "timeout",
+ 'type' => Int32,
+ 'value' => "5000",
+ ),
+ ),
+ ));
+
+DefineFunction(
+ array(
+ 'name' => "get",
+ 'flags' => HasDocComment,
+ 'return' => array(
+ 'type' => Variant,
+ ),
+ 'args' => array(
+ array(
+ 'name' => "key",
+ 'type' => String,
+ ),
+ array(
+ 'name' => "timeout",
+ 'type' => Int32,
+ 'value' => "5000",
+ ),
+ ),
+ ));
+
+DefineFunction(
+ array(
+ 'name' => "__destruct",
+ 'flags' => HasDocComment,
+ 'return' => array(
+ 'type' => Variant,
+ ),
+ ));
+
+EndClass(
+);
+
+///////////////////////////////////////////////////////////////////////////////
+
+BeginClass(
+ array(
+ 'name' => "_Libredis_Batch",
+ 'bases' => array('Sweepable'),
+ 'flags' => HasDocComment,
+ 'footer' => <<<EOT
+
+ public:
+ Batch *getBatch();
+
+ private:
+ Batch *m_batch;
+EOT
+,
+ ));
+
+DefineFunction(
+ array(
+ 'name' => "__construct",
+ 'flags' => HasDocComment,
+ 'return' => array(
+ 'type' => null,
+ ),
+ ));
+
+DefineFunction(
+ array(
+ 'name' => "write",
+ 'flags' => HasDocComment,
+ 'return' => array(
+ 'type' => null,
+ ),
+ 'args' => array(
+ array(
+ 'name' => "str",
+ 'type' => String,
+ ),
+ array(
+ 'name' => "num_commands",
+ 'type' => Int32,
+ 'value' => "0",
+ ),
+ ),
+ ));
+
+DefineFunction(
+ array(
+ 'name' => "set",
+ 'flags' => HasDocComment,
+ 'return' => array(
+ 'type' => Object,
+ ),
+ 'args' => array(
+ array(
+ 'name' => "key",
+ 'type' => String,
+ ),
+ array(
+ 'name' => "value",
+ 'type' => String,
+ ),
+ ),
+ ));
+
+DefineFunction(
+ array(
+ 'name' => "get",
+ 'flags' => HasDocComment,
+ 'return' => array(
+ 'type' => Object,
+ ),
+ 'args' => array(
+ array(
+ 'name' => "key",
+ 'type' => String,
+ ),
+ ),
+ ));
+
+DefineFunction(
+ array(
+ 'name' => "cmd",
+ 'flags' => HasDocComment | VariableArguments,
+ 'return' => array(
+ 'type' => null,
+ ),
+ ));
+
+DefineFunction(
+ array(
+ 'name' => "next_reply",
+ 'flags' => HasDocComment,
+ 'return' => array(
+ 'type' => Int32,
+ ),
+ 'args' => array(
+ array(
+ 'name' => "reply_type",
+ 'type' => Variant | Reference,
+ ),
+ array(
+ 'name' => "reply_value",
+ 'type' => Variant | Reference,
+ ),
+ array(
+ 'name' => "reply_length",
+ 'type' => Variant | Reference,
+ ),
+ ),
+ ));
+
+DefineFunction(
+ array(
+ 'name' => "execute",
+ 'flags' => HasDocComment,
+ 'return' => array(
+ 'type' => Boolean,
+ ),
+ 'args' => array(
+ array(
+ 'name' => "connection",
+ 'type' => Object,
+ ),
+ array(
+ 'name' => "timeout",
+ 'type' => Int32,
+ 'value' => "5000",
+ ),
+ ),
+ ));
+
+DefineFunction(
+ array(
+ 'name' => "__destruct",
+ 'flags' => HasDocComment,
+ 'return' => array(
+ 'type' => Variant,
+ ),
+ ));
+
+EndClass(
+);
+
+///////////////////////////////////////////////////////////////////////////////
+
+BeginClass(
+ array(
+ 'name' => "_Libredis_Redis",
+ 'bases' => array('Sweepable'),
+ 'flags' => HasDocComment,
+ 'footer' => <<<EOT
+
+ public:
+ static void updateLastError();
+
+ private:
+ static DECLARE_THREAD_LOCAL(std::string, m_lastError);
+EOT
+,
+ ));
+
+DefineFunction(
+ array(
+ 'name' => "__construct",
+ 'flags' => HasDocComment,
+ 'return' => array(
+ 'type' => null,
+ ),
+ ));
+
+DefineFunction(
+ array(
+ 'name' => "create_ketama",
+ 'flags' => HasDocComment,
+ 'return' => array(
+ 'type' => Object,
+ ),
+ ));
+
+DefineFunction(
+ array(
+ 'name' => "create_executor",
+ 'flags' => HasDocComment,
+ 'return' => array(
+ 'type' => Object,
+ ),
+ ));
+
+DefineFunction(
+ array(
+ 'name' => "last_error",
+ 'flags' => HasDocComment,
+ 'return' => array(
+ 'type' => String,
+ ),
+ ));
+
+DefineFunction(
+ array(
+ 'name' => "get_connection",
+ 'flags' => HasDocComment,
+ 'return' => array(
+ 'type' => Object,
+ ),
+ 'args' => array(
+ array(
+ 'name' => "addr",
+ 'type' => String,
+ ),
+ ),
+ ));
+
+DefineFunction(
+ array(
+ 'name' => "create_batch",
+ 'flags' => HasDocComment,
+ 'return' => array(
+ 'type' => Object,
+ ),
+ 'args' => array(
+ array(
+ 'name' => "str",
+ 'type' => String,
+ 'value' => "null_string",
+ ),
+ array(
+ 'name' => "num_commands",
+ 'type' => Int32,
+ 'value' => "0",
+ ),
+ ),
+ ));
+
+DefineFunction(
+ array(
+ 'name' => "__destruct",
+ 'flags' => HasDocComment,
+ 'return' => array(
+ 'type' => Variant,
+ ),
+ ));
+
+EndClass(
+);
+
View
1 src/runtime/ext/ext.h
@@ -49,6 +49,7 @@
#include <runtime/ext/profile/extprofile_iterator.h>
#include <runtime/ext/profile/extprofile_json.h>
#include <runtime/ext/profile/extprofile_ldap.h>
+#include <runtime/ext/profile/extprofile_libredis.h>
#include <runtime/ext/profile/extprofile_magick.h>
#include <runtime/ext/profile/extprofile_mailparse.h>
#include <runtime/ext/profile/extprofile_math.h>
View
412 src/runtime/ext/ext_libredis.cpp
@@ -0,0 +1,412 @@
+/*
+ +----------------------------------------------------------------------+
+ | HipHop for PHP |
+ +----------------------------------------------------------------------+
+ | Copyright (c) 2010 Hyves (http://www.hyves.nl) |
+ | Copyright (c) 2010- Facebook, Inc. (http://www.facebook.com) |
+ | Copyright (c) 1997-2010 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. |
+ +----------------------------------------------------------------------+
+*/
+
+#include <runtime/ext/ext_libredis.h>
+
+using namespace std;
+
+namespace HPHP {
+///////////////////////////////////////////////////////////////////////////////
+
+IMPLEMENT_DEFAULT_EXTENSION(libredis);
+IMPLEMENT_THREAD_LOCAL(c__Libredis_Connection::ConnectionMap,
+ c__Libredis_Connection::s_persistentMap);
+IMPLEMENT_THREAD_LOCAL(std::string, c__Libredis_Redis::m_lastError);
+
+namespace {
+class LibredisModule {
+public:
+ LibredisModule() {
+ module = Module_new();
+ Module_init(module);
+ }
+
+ ~LibredisModule() {
+ Module_free(module);
+ }
+
+ Module *module;
+};
+
+static LibredisModule s_libredis_module;
+}
+
+Object f_libredis() {
+ return p__Libredis_Redis(NEWOBJ(c__Libredis_Redis)())->create();
+}
+
+///////////////////////////////////////////////////////////////////////////////
+// class _Libredis_Ketama
+
+c__Libredis_Ketama::c__Libredis_Ketama()
+ : m_ketama(Ketama_new()) { }
+c__Libredis_Ketama::~c__Libredis_Ketama() {
+ Ketama_free(m_ketama);
+}
+
+void c__Libredis_Ketama::t___construct() { }
+
+Variant c__Libredis_Ketama::t___destruct() {
+ INSTANCE_METHOD_INJECTION_BUILTIN(_Libredis_Ketama, _Libredis_Ketama::__destruct);
+ return null;
+}
+
+Ketama *c__Libredis_Ketama::getKetama() {
+ return m_ketama;
+}
+
+void c__Libredis_Ketama::t_add_server(CStrRef host, int port, int weight) {
+ INSTANCE_METHOD_INJECTION_BUILTIN(_Libredis_Ketama, _Libredis_Ketama::add_server);
+ Ketama_add_server(m_ketama, host.c_str(), port, weight);
+}
+
+int c__Libredis_Ketama::t_get_server_ordinal(CStrRef key) {
+ INSTANCE_METHOD_INJECTION_BUILTIN(_Libredis_Ketama, _Libredis_Ketama::get_server_ordinal);
+ return Ketama_get_server_ordinal(m_ketama, key.c_str(), key.length());
+}
+
+String c__Libredis_Ketama::t_get_server_address(int ordinal) {
+ INSTANCE_METHOD_INJECTION_BUILTIN(_Libredis_Ketama, _Libredis_Ketama::get_server_address);
+ return String(Ketama_get_server_address(m_ketama, ordinal), CopyString);
+}
+
+void c__Libredis_Ketama::t_create_continuum() {
+ INSTANCE_METHOD_INJECTION_BUILTIN(_Libredis_Ketama, _Libredis_Ketama::create_continuum);
+ Ketama_create_continuum(m_ketama);
+}
+
+///////////////////////////////////////////////////////////////////////////////
+// class _Libredis_Executor
+
+c__Libredis_Executor::c__Libredis_Executor()
+ : m_executor(Executor_new()) { }
+c__Libredis_Executor::~c__Libredis_Executor() {
+ Executor_free(m_executor);
+}
+
+void c__Libredis_Executor::t___construct() { }
+
+Variant c__Libredis_Executor::t___destruct() {
+ INSTANCE_METHOD_INJECTION_BUILTIN(_Libredis_Executor, _Libredis_Executor::__destruct);
+ return null;
+}
+
+Executor *c__Libredis_Executor::getExecutor() {
+ return m_executor;
+}
+
+Variant c__Libredis_Executor::t_add(CObjRef connection, CObjRef batch) {
+ INSTANCE_METHOD_INJECTION_BUILTIN(_Libredis_Executor, _Libredis_Executor::add);
+ c__Libredis_Connection *typedConnection =
+ connection.getTyped<c__Libredis_Connection>();
+ c__Libredis_Batch *typedBatch =
+ batch.getTyped<c__Libredis_Batch>();
+ Connection *redisConnection = typedConnection->getConnection();
+ if (!redisConnection || Executor_add(m_executor, redisConnection,
+ typedBatch->getBatch()) == -1) {
+ return null;
+ }
+ return true;
+}
+
+Variant c__Libredis_Executor::t_execute(int timeout /*= 5000*/) {
+ INSTANCE_METHOD_INJECTION_BUILTIN(_Libredis_Executor, _Libredis_Executor::execute);
+ int res = Executor_execute(m_executor, timeout);
+ if (res > 0) {
+ return true;
+ } else if (res == 0) {
+ c__Libredis_Redis::updateLastError();
+ return false;
+ } else {
+ raise_error("%s", Module_last_error(s_libredis_module.module));
+ return null;
+ }
+}
+
+///////////////////////////////////////////////////////////////////////////////
+// class _Libredis_Connection
+
+namespace {
+class ExecutorWrapper {
+public:
+ ExecutorWrapper() : executor(Executor_new()) { }
+ ~ExecutorWrapper() { Executor_free(executor); }
+ Executor *executor;
+};
+
+class BatchWrapper {
+public:
+ BatchWrapper() : batch(Batch_new()) { }
+ ~BatchWrapper() { Batch_free(batch); }
+ Batch *batch;
+};
+}
+
+c__Libredis_Connection::ConnectionWrapper::ConnectionWrapper(Connection *c)
+ : connection(c) { }
+c__Libredis_Connection::ConnectionWrapper::~ConnectionWrapper() {
+ Connection_free(connection);
+}
+
+c__Libredis_Connection::c__Libredis_Connection() { }
+c__Libredis_Connection::~c__Libredis_Connection() { }
+
+void c__Libredis_Connection::t___construct(CStrRef address) {
+ INSTANCE_METHOD_INJECTION_BUILTIN(_Libredis_Connection, _Libredis_Connection::__construct);
+ ConnectionPtr &connection = (*s_persistentMap)[address.c_str()];
+ if (!connection) {
+ Connection *newConnection = Connection_new(address);
+ if (!newConnection) {
+ raise_error("%s", Module_last_error(s_libredis_module.module));
+ return;
+ }
+ connection.reset(new ConnectionWrapper(newConnection));
+ }
+ m_connection = connection;
+}
+
+Variant c__Libredis_Connection::t___destruct() {
+ INSTANCE_METHOD_INJECTION_BUILTIN(_Libredis_Connection, _Libredis_Connection::__destruct);
+ return null;
+}
+
+Connection *c__Libredis_Connection::getConnection() {
+ return m_connection ? m_connection->connection : NULL;
+}
+
+bool c__Libredis_Connection::executeSimple(Batch *batch, int timeout) {
+ Connection *redisConnection = getConnection();
+ if (!redisConnection)
+ return false;
+ ExecutorWrapper executor;
+ Executor_add(executor.executor, redisConnection, batch);
+ int res = Executor_execute(executor.executor, timeout);
+ if (res < 0) {
+ raise_error("%s", Module_last_error(s_libredis_module.module));
+ }
+ return res == 1;
+}
+
+bool c__Libredis_Connection::t_execute(CObjRef batch, int timeout /*= 5000*/) {
+ INSTANCE_METHOD_INJECTION_BUILTIN(_Libredis_Connection, _Libredis_Connection::execute);
+ c__Libredis_Batch *typedBatch = batch.getTyped<c__Libredis_Batch>();
+ return executeSimple(typedBatch->getBatch(), timeout);
+}
+
+Variant c__Libredis_Connection::t_set(CStrRef key, CStrRef value,
+ int timeout /*= 5000*/) {
+ INSTANCE_METHOD_INJECTION_BUILTIN(_Libredis_Connection, _Libredis_Connection::set);
+ BatchWrapper batch;
+ Batch_write_set(batch.batch, key.c_str(), key.length(),
+ value.c_str(), value.length());
+ if (!executeSimple(batch.batch, timeout)) {
+ c__Libredis_Redis::updateLastError();
+ return false;
+ }
+ ReplyType replyType; char *replyValue; size_t replyLength;
+ int level = Batch_next_reply(batch.batch, &replyType,
+ &replyValue, &replyLength);
+ if (level != 1) {
+ raise_error("Unexpected level");
+ return null;
+ } else if (replyType == RT_OK) {
+ return true;
+ } else if (replyType == RT_ERROR) {
+ c__Libredis_Redis::updateLastError();
+ return false;
+ } else {
+ raise_error("Unexpected reply type");
+ return null;
+ }
+}
+
+Variant c__Libredis_Connection::t_get(CStrRef key, int timeout /*= 5000*/) {
+ INSTANCE_METHOD_INJECTION_BUILTIN(_Libredis_Connection, _Libredis_Connection::get);
+ BatchWrapper batch;
+ Batch_write_get(batch.batch, key.c_str(), key.length());
+ if (!executeSimple(batch.batch, timeout)) {
+ c__Libredis_Redis::updateLastError();
+ return false;
+ }
+ ReplyType replyType; char *replyValue; size_t replyLength;
+ int level = Batch_next_reply(batch.batch, &replyType,
+ &replyValue, &replyLength);
+ if (level != 1) {
+ raise_error("Unexpected level");
+ return null;
+ } else if (replyType == RT_BULK) {
+ if (replyValue && replyLength > 0) {
+ return String(replyValue, replyLength, CopyString);
+ } else {
+ return empty_string;
+ }
+ } else if (replyType == RT_BULK_NIL) {
+ return null;
+ } else if (replyType == RT_ERROR) {
+ c__Libredis_Redis::updateLastError();
+ return false;
+ } else {
+ raise_error("Unexpected reply type");
+ return null;
+ }
+}
+
+///////////////////////////////////////////////////////////////////////////////
+// class _Libredis_Batch
+
+c__Libredis_Batch::c__Libredis_Batch()
+ : m_batch(Batch_new()) { }
+c__Libredis_Batch::~c__Libredis_Batch() {
+ Batch_free(m_batch);
+}
+
+void c__Libredis_Batch::t___construct() { }
+
+Variant c__Libredis_Batch::t___destruct() {
+ INSTANCE_METHOD_INJECTION_BUILTIN(_Libredis_Batch, _Libredis_Batch::__destruct);
+ return null;
+}
+
+Batch *c__Libredis_Batch::getBatch() {
+ return m_batch;
+}
+
+void c__Libredis_Batch::t_write(CStrRef str, int num_commands /*= 0*/) {
+ INSTANCE_METHOD_INJECTION_BUILTIN(_Libredis_Batch, _Libredis_Batch::write);
+ Batch_write(m_batch, str.c_str(), str.length(), num_commands);
+}
+
+Object c__Libredis_Batch::t_set(CStrRef key, CStrRef value) {
+ INSTANCE_METHOD_INJECTION_BUILTIN(_Libredis_Batch, _Libredis_Batch::set);
+ Batch_write_set(m_batch, key.c_str(), key.length(),
+ value.c_str(), value.length());
+ return this;
+}
+
+Object c__Libredis_Batch::t_get(CStrRef key) {
+ INSTANCE_METHOD_INJECTION_BUILTIN(_Libredis_Batch, _Libredis_Batch::get);
+ Batch_write_get(m_batch, key.c_str(), key.length());
+ return this;
+}
+
+void c__Libredis_Batch::t_cmd(int _argc, CArrRef _argv /*= null_array*/) {
+ INSTANCE_METHOD_INJECTION_BUILTIN(_Libredis_Batch, _Libredis_Batch::cmd);
+ for (ArrayIter iter(_argv); iter; ++iter) {
+ if (!iter.second().isString()) {
+ raise_error("all arguments must be strings!");
+ return;
+ }
+ }
+ Batch_write(m_batch, "*", 1, 1);
+ Batch_write_decimal(m_batch, _argc);
+ Batch_write(m_batch, "\r\n", 2, 0);
+ for (ArrayIter iter(_argv); iter; ++iter) {
+ String value = iter.second().toString();
+ Batch_write(m_batch, "$", 1, 0);
+ Batch_write_decimal(m_batch, value.length());
+ Batch_write(m_batch, "\r\n", 2, 0);
+ Batch_write(m_batch, value.c_str(), value.length(), 0);
+ Batch_write(m_batch, "\r\n", 2, 0);
+ }
+}
+
+int c__Libredis_Batch::t_next_reply(VRefParam reply_type,
+ VRefParam reply_value,
+ VRefParam reply_length) {
+ INSTANCE_METHOD_INJECTION_BUILTIN(_Libredis_Batch, _Libredis_Batch::next_reply);
+ ReplyType replyType; char *replyValue; size_t replyLength;
+ int level = Batch_next_reply(m_batch, &replyType, &replyValue, &replyLength);
+ reply_type = replyType;
+ switch (replyType) {
+ case RT_OK:
+ case RT_ERROR:
+ case RT_BULK:
+ if (replyValue && replyLength > 0) {
+ reply_value = String(replyValue, replyLength, CopyString);
+ } else {
+ reply_value = empty_string;
+ }
+ break;
+ case RT_INTEGER:
+ reply_value = (int)strtol(replyValue, NULL, 10);
+ break;
+ default:
+ reply_value = null;
+ break;
+ }
+ reply_length = (int)replyLength;
+ return level;
+}
+
+bool c__Libredis_Batch::t_execute(CObjRef connection, int timeout /*= 5000*/) {
+ INSTANCE_METHOD_INJECTION_BUILTIN(_Libredis_Batch, _Libredis_Batch::execute);
+ c__Libredis_Connection *typedConnection =
+ connection.getTyped<c__Libredis_Connection>();
+ return typedConnection->executeSimple(m_batch, timeout);
+}
+
+///////////////////////////////////////////////////////////////////////////////
+// class _Libredis_Redis
+
+c__Libredis_Redis::c__Libredis_Redis() { }
+c__Libredis_Redis::~c__Libredis_Redis() { }
+
+void c__Libredis_Redis::t___construct() { }
+
+Variant c__Libredis_Redis::t___destruct() {
+ INSTANCE_METHOD_INJECTION_BUILTIN(_Libredis_Redis, _Libredis_Redis::__destruct);
+ return null;
+}
+
+void c__Libredis_Redis::updateLastError() {
+ *m_lastError = Module_last_error(s_libredis_module.module);
+}
+
+Object c__Libredis_Redis::t_create_ketama() {
+ INSTANCE_METHOD_INJECTION_BUILTIN(_Libredis_Redis, _Libredis_Redis::create_ketama);
+ return p__Libredis_Ketama(NEWOBJ(c__Libredis_Ketama))->create();
+}
+
+Object c__Libredis_Redis::t_create_executor() {
+ INSTANCE_METHOD_INJECTION_BUILTIN(_Libredis_Redis, _Libredis_Redis::create_executor);
+ return p__Libredis_Executor(NEWOBJ(c__Libredis_Executor))->create();
+}
+
+String c__Libredis_Redis::t_last_error() {
+ INSTANCE_METHOD_INJECTION_BUILTIN(_Libredis_Redis, _Libredis_Redis::last_error);
+ return *m_lastError;
+}
+
+Object c__Libredis_Redis::t_get_connection(CStrRef addr) {
+ INSTANCE_METHOD_INJECTION_BUILTIN(_Libredis_Redis, _Libredis_Redis::get_connection);
+ return p__Libredis_Connection(NEWOBJ(c__Libredis_Connection))->create(addr);
+}
+
+Object c__Libredis_Redis::t_create_batch(CStrRef str /*= null_string*/,
+ int num_commands /*= 0*/) {
+ INSTANCE_METHOD_INJECTION_BUILTIN(_Libredis_Redis, _Libredis_Redis::create_batch);
+ p__Libredis_Batch batch(p__Libredis_Batch(
+ NEWOBJ(c__Libredis_Batch))->create());
+ if (!str.isNull()) {
+ batch->t_write(str, num_commands);
+ }
+ return batch;
+}
+
+///////////////////////////////////////////////////////////////////////////////
+}
View
236 src/runtime/ext/ext_libredis.h
@@ -0,0 +1,236 @@
+/*
+ +----------------------------------------------------------------------+
+ | HipHop for PHP |
+ +----------------------------------------------------------------------+
+ | Copyright (c) 2010 Hyves (http://www.hyves.nl) |
+ | Copyright (c) 2010- Facebook, Inc. (http://www.facebook.com) |
+ | Copyright (c) 1997-2010 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. |
+ +----------------------------------------------------------------------+
+*/
+
+#ifndef __EXT_LIBREDIS_H__
+#define __EXT_LIBREDIS_H__
+
+// >>>>>> Generated by idl.php. Do NOT modify. <<<<<<
+
+#include <runtime/base/base_includes.h>
+#include <libredis/redis.h>
+namespace HPHP {
+///////////////////////////////////////////////////////////////////////////////
+
+Object f_libredis();
+
+///////////////////////////////////////////////////////////////////////////////
+// class _Libredis_Ketama
+
+FORWARD_DECLARE_CLASS_BUILTIN(_Libredis_Ketama);
+class c__Libredis_Ketama : public ExtObjectData, public Sweepable {
+ public:
+ BEGIN_CLASS_MAP(_Libredis_Ketama)
+ END_CLASS_MAP(_Libredis_Ketama)
+ DECLARE_CLASS(_Libredis_Ketama, _Libredis_Ketama, ObjectData)
+
+ // need to implement
+ public: c__Libredis_Ketama();
+ public: ~c__Libredis_Ketama();
+ public: void t___construct();
+ DECLARE_METHOD_INVOKE_HELPERS(__construct);
+ public: void t_add_server(CStrRef host, int port, int weight);
+ DECLARE_METHOD_INVOKE_HELPERS(add_server);
+ public: int t_get_server_ordinal(CStrRef key);
+ DECLARE_METHOD_INVOKE_HELPERS(get_server_ordinal);
+ public: String t_get_server_address(int ordinal);
+ DECLARE_METHOD_INVOKE_HELPERS(get_server_address);
+ public: void t_create_continuum();
+ DECLARE_METHOD_INVOKE_HELPERS(create_continuum);
+ public: Variant t___destruct();
+ DECLARE_METHOD_INVOKE_HELPERS(__destruct);
+
+ // implemented by HPHP
+ public: c__Libredis_Ketama *create();
+ public: void dynConstruct(CArrRef Params);
+ public: void getConstructor(MethodCallPackage &mcp);
+
+ public:
+ Ketama *getKetama();
+
+ private:
+ Ketama *m_ketama;
+};
+
+///////////////////////////////////////////////////////////////////////////////
+// class _Libredis_Executor
+
+FORWARD_DECLARE_CLASS_BUILTIN(_Libredis_Executor);
+class c__Libredis_Executor : public ExtObjectData, public Sweepable {
+ public:
+ BEGIN_CLASS_MAP(_Libredis_Executor)
+ END_CLASS_MAP(_Libredis_Executor)
+ DECLARE_CLASS(_Libredis_Executor, _Libredis_Executor, ObjectData)
+
+ // need to implement
+ public: c__Libredis_Executor();
+ public: ~c__Libredis_Executor();
+ public: void t___construct();
+ DECLARE_METHOD_INVOKE_HELPERS(__construct);
+ public: Variant t_add(CObjRef connection, CObjRef batch);
+ DECLARE_METHOD_INVOKE_HELPERS(add);
+ public: Variant t_execute(int timeout = 5000);
+ DECLARE_METHOD_INVOKE_HELPERS(execute);
+ public: Variant t___destruct();
+ DECLARE_METHOD_INVOKE_HELPERS(__destruct);
+
+ // implemented by HPHP
+ public: c__Libredis_Executor *create();
+ public: void dynConstruct(CArrRef Params);
+ public: void getConstructor(MethodCallPackage &mcp);
+
+ public:
+ Executor *getExecutor();
+
+ private:
+ Executor *m_executor;
+};
+
+///////////////////////////////////////////////////////////////////////////////
+// class _Libredis_Connection
+
+FORWARD_DECLARE_CLASS_BUILTIN(_Libredis_Connection);
+class c__Libredis_Connection : public ExtObjectData, public Sweepable {
+ public:
+ BEGIN_CLASS_MAP(_Libredis_Connection)
+ END_CLASS_MAP(_Libredis_Connection)
+ DECLARE_CLASS(_Libredis_Connection, _Libredis_Connection, ObjectData)
+
+ // need to implement
+ public: c__Libredis_Connection();
+ public: ~c__Libredis_Connection();
+ public: void t___construct(CStrRef address);
+ DECLARE_METHOD_INVOKE_HELPERS(__construct);
+ public: bool t_execute(CObjRef batch, int timeout = 5000);
+ DECLARE_METHOD_INVOKE_HELPERS(execute);
+ public: Variant t_set(CStrRef key, CStrRef value, int timeout = 5000);
+ DECLARE_METHOD_INVOKE_HELPERS(set);
+ public: Variant t_get(CStrRef key, int timeout = 5000);
+ DECLARE_METHOD_INVOKE_HELPERS(get);
+ public: Variant t___destruct();
+ DECLARE_METHOD_INVOKE_HELPERS(__destruct);
+
+ // implemented by HPHP
+ public: c__Libredis_Connection *create(String address);
+ public: void dynConstruct(CArrRef Params);
+ public: void getConstructor(MethodCallPackage &mcp);
+
+ public:
+ Connection *getConnection();
+ bool executeSimple(Batch *batch, int timeout);
+
+ private:
+ class ConnectionWrapper {
+ public:
+ ConnectionWrapper(Connection *c);
+ ~ConnectionWrapper();
+ Connection *connection;
+ };
+ typedef boost::shared_ptr<ConnectionWrapper> ConnectionPtr;
+
+ ConnectionPtr m_connection;
+
+ typedef std::map<std::string, ConnectionPtr> ConnectionMap;
+ static DECLARE_THREAD_LOCAL(ConnectionMap, s_persistentMap);
+};
+
+///////////////////////////////////////////////////////////////////////////////
+// class _Libredis_Batch
+
+FORWARD_DECLARE_CLASS_BUILTIN(_Libredis_Batch);
+class c__Libredis_Batch : public ExtObjectData, public Sweepable {
+ public:
+ BEGIN_CLASS_MAP(_Libredis_Batch)
+ END_CLASS_MAP(_Libredis_Batch)
+ DECLARE_CLASS(_Libredis_Batch, _Libredis_Batch, ObjectData)
+
+ // need to implement
+ public: c__Libredis_Batch();
+ public: ~c__Libredis_Batch();
+ public: void t___construct();
+ DECLARE_METHOD_INVOKE_HELPERS(__construct);
+ public: void t_write(CStrRef str, int num_commands = 0);
+ DECLARE_METHOD_INVOKE_HELPERS(write);
+ public: Object t_set(CStrRef key, CStrRef value);
+ DECLARE_METHOD_INVOKE_HELPERS(set);
+ public: Object t_get(CStrRef key);
+ DECLARE_METHOD_INVOKE_HELPERS(get);
+ public: void t_cmd(int _argc, CArrRef _argv = null_array);
+ DECLARE_METHOD_INVOKE_HELPERS(cmd);
+ public: int t_next_reply(VRefParam reply_type, VRefParam reply_value, VRefParam reply_length);
+ DECLARE_METHOD_INVOKE_HELPERS(next_reply);
+ public: bool t_execute(CObjRef connection, int timeout = 5000);
+ DECLARE_METHOD_INVOKE_HELPERS(execute);
+ public: Variant t___destruct();
+ DECLARE_METHOD_INVOKE_HELPERS(__destruct);
+
+ // implemented by HPHP
+ public: c__Libredis_Batch *create();
+ public: void dynConstruct(CArrRef Params);
+ public: void getConstructor(MethodCallPackage &mcp);
+
+ public:
+ Batch *getBatch();
+
+ private:
+ Batch *m_batch;
+};
+
+///////////////////////////////////////////////////////////////////////////////
+// class _Libredis_Redis
+
+FORWARD_DECLARE_CLASS_BUILTIN(_Libredis_Redis);
+class c__Libredis_Redis : public ExtObjectData, public Sweepable {
+ public:
+ BEGIN_CLASS_MAP(_Libredis_Redis)
+ END_CLASS_MAP(_Libredis_Redis)
+ DECLARE_CLASS(_Libredis_Redis, _Libredis_Redis, ObjectData)
+
+ // need to implement
+ public: c__Libredis_Redis();
+ public: ~c__Libredis_Redis();
+ public: void t___construct();
+ DECLARE_METHOD_INVOKE_HELPERS(__construct);
+ public: Object t_create_ketama();
+ DECLARE_METHOD_INVOKE_HELPERS(create_ketama);
+ public: Object t_create_executor();
+ DECLARE_METHOD_INVOKE_HELPERS(create_executor);
+ public: String t_last_error();
+ DECLARE_METHOD_INVOKE_HELPERS(last_error);
+ public: Object t_get_connection(CStrRef addr);
+ DECLARE_METHOD_INVOKE_HELPERS(get_connection);
+ public: Object t_create_batch(CStrRef str = null_string, int num_commands = 0);
+ DECLARE_METHOD_INVOKE_HELPERS(create_batch);
+ public: Variant t___destruct();
+ DECLARE_METHOD_INVOKE_HELPERS(__destruct);
+
+ // implemented by HPHP
+ public: c__Libredis_Redis *create();
+ public: void dynConstruct(CArrRef Params);
+ public: void getConstructor(MethodCallPackage &mcp);
+
+ public:
+ static void updateLastError();
+
+ private:
+ static DECLARE_THREAD_LOCAL(std::string, m_lastError);
+};
+
+///////////////////////////////////////////////////////////////////////////////
+}
+
+#endif // __EXT_LIBREDIS_H__
View
38 src/runtime/ext/profile/extprofile_libredis.h
@@ -0,0 +1,38 @@
+/*
+ +----------------------------------------------------------------------+
+ | HipHop for PHP |
+ +----------------------------------------------------------------------+
+ | Copyright (c) 2010- Facebook, Inc. (http://www.facebook.com) |
+ | Copyright (c) 1997-2010 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. |
+ +----------------------------------------------------------------------+
+*/
+
+#ifndef __EXTPROFILE_LIBREDIS_H__
+#define __EXTPROFILE_LIBREDIS_H__
+
+// >>>>>> Generated by idl.php. Do NOT modify. <<<<<<
+
+#include <runtime/ext/ext_libredis.h>
+
+namespace HPHP {
+///////////////////////////////////////////////////////////////////////////////
+
+inline Object x_libredis() {
+ FUNCTION_INJECTION_BUILTIN(libredis);
+ TAINT_OBSERVER(TAINT_BIT_NONE, TAINT_BIT_NONE);
+ return f_libredis();
+}
+
+
+///////////////////////////////////////////////////////////////////////////////
+}
+
+#endif // __EXTPROFILE_LIBREDIS_H__
View
1 src/system/ext.inc
@@ -32,6 +32,7 @@
#include "iterator.inc"
#include "json.inc"
#include "ldap.inc"
+#include "libredis.inc"
#include "magick.inc"
#include "mailparse.inc"
#include "math.inc"
View
17 src/system/libredis.inc
@@ -0,0 +1,17 @@
+// @generated by "php idl.php inc {input.idl.php} {output.inc}"
+
+#if EXT_TYPE == 0
+"libredis", T(Object), S(0), NULL, S(16384), "/**\n * ( excerpt from http://php.net/manual/en/function.libredis.php )\n *\n *\n * @return object\n */",
+
+#elif EXT_TYPE == 1
+
+#elif EXT_TYPE == 2
+"_Libredis_Ketama", "", NULL, "__construct", T(Void), S(0), NULL, S(16384), "/**\n * ( excerpt from http://php.net/manual/en/-libredis-ketama.--construct.php\n * )\n *\n *\n */", S(16384),"add_server", T(Void), S(0), "host", T(String), NULL, NULL, S(0), "port", T(Int32), NULL, NULL, S(0), "weight", T(Int32), NULL, NULL, S(0), NULL, S(16384), "/**\n * ( excerpt from http://php.net/manual/en/-libredis-ketama.add-server.php\n * )\n *\n *\n * @host string\n * @port int\n * @weight int\n */", S(16384),"get_server_ordinal", T(Int32), S(0), "key", T(String), NULL, NULL, S(0), NULL, S(16384), "/**\n * ( excerpt from\n * http://php.net/manual/en/-libredis-ketama.get-server-ordinal.php )\n *\n *\n * @key string\n *\n * @return int\n */", S(16384),"get_server_address", T(String), S(0), "ordinal", T(Int32), NULL, NULL, S(0), NULL, S(16384), "/**\n * ( excerpt from\n * http://php.net/manual/en/-libredis-ketama.get-server-address.php )\n *\n *\n * @ordinal int\n *\n * @return string\n */", S(16384),"create_continuum", T(Void), S(0), NULL, S(16384), "/**\n * ( excerpt from\n * http://php.net/manual/en/-libredis-ketama.create-continuum.php )\n *\n *\n */", S(16384),"__destruct", T(Variant), S(0), NULL, S(16384), "/**\n * ( excerpt from http://php.net/manual/en/-libredis-ketama.--destruct.php\n * )\n *\n *\n * @return mixed\n */", S(16384),NULL,NULL,NULL,
+S(16384), "/**\n * ( excerpt from http://php.net/manual/en/class.-libredis-ketama.php )\n *\n *\n */", "_Libredis_Executor", "", NULL, "__construct", T(Void), S(0), NULL, S(16384), "/**\n * ( excerpt from\n * http://php.net/manual/en/-libredis-executor.--construct.php )\n *\n *\n */", S(16384),"add", T(Variant), S(0), "connection", T(Object), NULL, NULL, S(0), "batch", T(Object), NULL, NULL, S(0), NULL, S(16384), "/**\n * ( excerpt from http://php.net/manual/en/-libredis-executor.add.php )\n *\n *\n * @connection object\n * @batch object\n *\n * @return mixed\n */", S(16384),"execute", T(Variant), S(0), "timeout", T(Int32), "i:5000;", "5000", S(0), NULL, S(16384), "/**\n * ( excerpt from http://php.net/manual/en/-libredis-executor.execute.php )\n *\n *\n * @timeout int\n *\n * @return mixed\n */", S(16384),"__destruct", T(Variant), S(0), NULL, S(16384), "/**\n * ( excerpt from\n * http://php.net/manual/en/-libredis-executor.--destruct.php )\n *\n *\n * @return mixed\n */", S(16384),NULL,NULL,NULL,
+S(16384), "/**\n * ( excerpt from http://php.net/manual/en/class.-libredis-executor.php )\n *\n *\n */", "_Libredis_Connection", "", NULL, "__construct", T(Void), S(0), "address", T(String), NULL, NULL, S(0), NULL, S(16384), "/**\n * ( excerpt from\n * http://php.net/manual/en/-libredis-connection.--construct.php )\n *\n *\n * @address string\n */", S(16384),"execute", T(Boolean), S(0), "batch", T(Object), NULL, NULL, S(0), "timeout", T(Int32), "i:5000;", "5000", S(0), NULL, S(16384), "/**\n * ( excerpt from http://php.net/manual/en/-libredis-connection.execute.php\n * )\n *\n *\n * @batch object\n * @timeout int\n *\n * @return bool\n */", S(16384),"set", T(Variant), S(0), "key", T(String), NULL, NULL, S(0), "value", T(String), NULL, NULL, S(0), "timeout", T(Int32), "i:5000;", "5000", S(0), NULL, S(16384), "/**\n * ( excerpt from http://php.net/manual/en/-libredis-connection.set.php )\n *\n *\n * @key string\n * @value string\n * @timeout int\n *\n * @return mixed\n */", S(16384),"get", T(Variant), S(0), "key", T(String), NULL, NULL, S(0), "timeout", T(Int32), "i:5000;", "5000", S(0), NULL, S(16384), "/**\n * ( excerpt from http://php.net/manual/en/-libredis-connection.get.php )\n *\n *\n * @key string\n * @timeout int\n *\n * @return mixed\n */", S(16384),"__destruct", T(Variant), S(0), NULL, S(16384), "/**\n * ( excerpt from\n * http://php.net/manual/en/-libredis-connection.--destruct.php )\n *\n *\n * @return mixed\n */", S(16384),NULL,NULL,NULL,
+S(16384), "/**\n * ( excerpt from http://php.net/manual/en/class.-libredis-connection.php )\n *\n *\n */", "_Libredis_Batch", "", NULL, "__construct", T(Void), S(0), NULL, S(16384), "/**\n * ( excerpt from http://php.net/manual/en/-libredis-batch.--construct.php\n * )\n *\n *\n */", S(16384),"write", T(Void), S(0), "str", T(String), NULL, NULL, S(0), "num_commands", T(Int32), "i:0;", "0", S(0), NULL, S(16384), "/**\n * ( excerpt from http://php.net/manual/en/-libredis-batch.write.php )\n *\n *\n * @str string\n * @num_commands\n * int\n */", S(16384),"set", T(Object), S(0), "key", T(String), NULL, NULL, S(0), "value", T(String), NULL, NULL, S(0), NULL, S(16384), "/**\n * ( excerpt from http://php.net/manual/en/-libredis-batch.set.php )\n *\n *\n * @key string\n * @value string\n *\n * @return object\n */", S(16384),"get", T(Object), S(0), "key", T(String), NULL, NULL, S(0), NULL, S(16384), "/**\n * ( excerpt from http://php.net/manual/en/-libredis-batch.get.php )\n *\n *\n * @key string\n *\n * @return object\n */", S(16384),"cmd", T(Void), S(0), NULL, S(147456), "/**\n * ( excerpt from http://php.net/manual/en/-libredis-batch.cmd.php )\n *\n *\n */", S(147456),"next_reply", T(Int32), S(0), "reply_type", T(Variant), NULL, NULL, S(1), "reply_value", T(Variant), NULL, NULL, S(1), "reply_length", T(Variant), NULL, NULL, S(1), NULL, S(16384), "/**\n * ( excerpt from http://php.net/manual/en/-libredis-batch.next-reply.php )\n *\n *\n * @reply_type mixed\n * @reply_value\n * mixed\n * @reply_length\n * mixed\n *\n * @return int\n */", S(16384),"execute", T(Boolean), S(0), "connection", T(Object), NULL, NULL, S(0), "timeout", T(Int32), "i:5000;", "5000", S(0), NULL, S(16384), "/**\n * ( excerpt from http://php.net/manual/en/-libredis-batch.execute.php )\n *\n *\n * @connection object\n * @timeout int\n *\n * @return bool\n */", S(16384),"__destruct", T(Variant), S(0), NULL, S(16384), "/**\n * ( excerpt from http://php.net/manual/en/-libredis-batch.--destruct.php )\n *\n *\n * @return mixed\n */", S(16384),NULL,NULL,NULL,
+S(16384), "/**\n * ( excerpt from http://php.net/manual/en/class.-libredis-batch.php )\n *\n *\n */", "_Libredis_Redis", "", NULL, "__construct", T(Void), S(0), NULL, S(16384), "/**\n * ( excerpt from http://php.net/manual/en/-libredis-redis.--construct.php\n * )\n *\n *\n */", S(16384),"create_ketama", T(Object), S(0), NULL, S(16384), "/**\n * ( excerpt from\n * http://php.net/manual/en/-libredis-redis.create-ketama.php )\n *\n *\n * @return object\n */", S(16384),"create_executor", T(Object), S(0), NULL, S(16384), "/**\n * ( excerpt from\n * http://php.net/manual/en/-libredis-redis.create-executor.php )\n *\n *\n * @return object\n */", S(16384),"last_error", T(String), S(0), NULL, S(16384), "/**\n * ( excerpt from http://php.net/manual/en/-libredis-redis.last-error.php )\n *\n *\n * @return string\n */", S(16384),"get_connection", T(Object), S(0), "addr", T(String), NULL, NULL, S(0), NULL, S(16384), "/**\n * ( excerpt from\n * http://php.net/manual/en/-libredis-redis.get-connection.php )\n *\n *\n * @addr string\n *\n * @return object\n */", S(16384),"create_batch", T(Object), S(0), "str", T(String), "N;", "null", S(0), "num_commands", T(Int32), "i:0;", "0", S(0), NULL, S(16384), "/**\n * ( excerpt from http://php.net/manual/en/-libredis-redis.create-batch.php\n * )\n *\n *\n * @str string\n * @num_commands\n * int\n *\n * @return object\n */", S(16384),"__destruct", T(Variant), S(0), NULL, S(16384), "/**\n * ( excerpt from http://php.net/manual/en/-libredis-redis.--destruct.php )\n *\n *\n * @return mixed\n */", S(16384),NULL,NULL,NULL,
+S(16384), "/**\n * ( excerpt from http://php.net/manual/en/class.-libredis-redis.php )\n *\n *\n */",
+#elif EXT_TYPE == 3
+
+#endif
View
1 src/test/test_ext.h
@@ -47,6 +47,7 @@
#include <test/test_ext_iterator.h>
#include <test/test_ext_json.h>
#include <test/test_ext_ldap.h>
+#include <test/test_ext_libredis.h>
#include <test/test_ext_magick.h>
#include <test/test_ext_mailparse.h>
#include <test/test_ext_math.h>
View
1 src/test/test_ext.inc
@@ -32,6 +32,7 @@ RUN_TESTSUITE(TestExtIpc);
RUN_TESTSUITE(TestExtIterator);
RUN_TESTSUITE(TestExtJson);
RUN_TESTSUITE(TestExtLdap);
+RUN_TESTSUITE(TestExtLibredis);
RUN_TESTSUITE(TestExtMagick);
RUN_TESTSUITE(TestExtMailparse);
RUN_TESTSUITE(TestExtMath);
View
62 src/test/test_ext_libredis.cpp
@@ -0,0 +1,62 @@
+/*
+ +----------------------------------------------------------------------+
+ | HipHop for PHP |
+ +----------------------------------------------------------------------+
+ | Copyright (c) 2010 Hyves (http://www.hyves.nl) |
+ | Copyright (c) 2010- Facebook, Inc. (http://www.facebook.com) |
+ | Copyright (c) 1997-2010 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. |
+ +----------------------------------------------------------------------+
+*/
+
+#include <test/test_ext_libredis.h>
+#include <runtime/ext/ext_libredis.h>
+
+IMPLEMENT_SEP_EXTENSION_TEST(Libredis);
+///////////////////////////////////////////////////////////////////////////////
+
+bool TestExtLibredis::RunTests(const std::string &which) {
+ bool ret = true;
+
+ RUN_TEST(test_libredis);
+ RUN_TEST(test__Libredis_Ketama);
+ RUN_TEST(test__Libredis_Executor);
+ RUN_TEST(test__Libredis_Connection);
+ RUN_TEST(test__Libredis_Batch);
+ RUN_TEST(test__Libredis_Redis);
+
+ return ret;
+}
+
+///////////////////////////////////////////////////////////////////////////////
+
+bool TestExtLibredis::test_libredis() {
+ return Count(true);
+}
+
+bool TestExtLibredis::test__Libredis_Ketama() {
+ return Count(true);
+}
+
+bool TestExtLibredis::test__Libredis_Executor() {
+ return Count(true);
+}
+
+bool TestExtLibredis::test__Libredis_Connection() {
+ return Count(true);
+}
+
+bool TestExtLibredis::test__Libredis_Batch() {
+ return Count(true);
+}
+
+bool TestExtLibredis::test__Libredis_Redis() {
+ return Count(true);
+}
View
42 src/test/test_ext_libredis.h
@@ -0,0 +1,42 @@
+/*
+ +----------------------------------------------------------------------+
+ | HipHop for PHP |
+ +----------------------------------------------------------------------+
+ | Copyright (c) 2010 Hyves (http://www.hyves.nl) |
+ | Copyright (c) 2010- Facebook, Inc. (http://www.facebook.com) |
+ | Copyright (c) 1997-2010 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. |
+ +----------------------------------------------------------------------+
+*/
+
+#ifndef __TEST_EXT_LIBREDIS_H__
+#define __TEST_EXT_LIBREDIS_H__
+
+// >>>>>> Generated by idl.php. Do NOT modify. <<<<<<
+
+#include <test/test_cpp_ext.h>
+
+///////////////////////////////////////////////////////////////////////////////
+
+class TestExtLibredis : public TestCppExt {
+ public:
+ virtual bool RunTests(const std::string &which);
+
+ bool test_libredis();
+ bool test__Libredis_Ketama();
+ bool test__Libredis_Executor();
+ bool test__Libredis_Connection();
+ bool test__Libredis_Batch();
+ bool test__Libredis_Redis();
+};
+
+///////////////////////////////////////////////////////////////////////////////
+
+#endif // __TEST_EXT_LIBREDIS_H__

0 comments on commit b7a2e4a

Please sign in to comment.
Something went wrong with that request. Please try again.