@@ -3265,6 +3265,32 @@ static PHP_METHOD(Memcached, setSaslAuthData)
32653265/* }}} */
32663266#endif /* HAVE_MEMCACHED_SASL */
32673267
3268+ #ifdef HAVE_MEMCACHED_SET_ENCODING_KEY
3269+ /* {{{ Memcached::setEncodingKey(string key)
3270+ Sets AES encryption key (libmemcached 1.0.6 and higher) */
3271+ static PHP_METHOD (Memcached , setEncodingKey )
3272+ {
3273+ MEMC_METHOD_INIT_VARS ;
3274+ memcached_return status ;
3275+ zend_string * key ;
3276+
3277+ /* "S" */
3278+ ZEND_PARSE_PARAMETERS_START (1 , 1 )
3279+ Z_PARAM_STR (key )
3280+ ZEND_PARSE_PARAMETERS_END ();
3281+
3282+ MEMC_METHOD_FETCH_OBJECT ;
3283+
3284+ status = memcached_set_encoding_key (intern -> memc , ZSTR_VAL (key ), ZSTR_LEN (key ));
3285+
3286+ if (s_memc_status_handle_result_code (intern , status ) == FAILURE ) {
3287+ RETURN_FALSE ;
3288+ }
3289+ RETURN_TRUE ;
3290+ }
3291+ /* }}} */
3292+ #endif /* HAVE_MEMCACHED_SET_ENCODING_KEY */
3293+
32683294/* {{{ Memcached::getResultCode()
32693295 Returns the result code from the last operation */
32703296static PHP_METHOD (Memcached , getResultCode )
@@ -4034,6 +4060,12 @@ ZEND_BEGIN_ARG_INFO(arginfo_setSaslAuthData, 0)
40344060ZEND_END_ARG_INFO ()
40354061#endif
40364062
4063+ #ifdef HAVE_MEMCACHED_SET_ENCODING_KEY
4064+ ZEND_BEGIN_ARG_INFO (arginfo_setEncodingKey , 0 )
4065+ ZEND_ARG_INFO (0 , key )
4066+ ZEND_END_ARG_INFO ()
4067+ #endif
4068+
40374069ZEND_BEGIN_ARG_INFO (arginfo_setOption , 0 )
40384070 ZEND_ARG_INFO (0 , option )
40394071 ZEND_ARG_INFO (0 , value )
@@ -4133,6 +4165,9 @@ static zend_function_entry memcached_class_methods[] = {
41334165 MEMC_ME (setBucket , arginfo_setBucket )
41344166#ifdef HAVE_MEMCACHED_SASL
41354167 MEMC_ME (setSaslAuthData , arginfo_setSaslAuthData )
4168+ #endif
4169+ #ifdef HAVE_MEMCACHED_SET_ENCODING_KEY
4170+ MEMC_ME (setEncodingKey , arginfo_setEncodingKey )
41364171#endif
41374172 MEMC_ME (isPersistent , arginfo_isPersistent )
41384173 MEMC_ME (isPristine , arginfo_isPristine )
@@ -4282,6 +4317,15 @@ static void php_memc_register_constants(INIT_FUNC_ARGS)
42824317 REGISTER_MEMC_CLASS_CONST_BOOL (HAVE_MSGPACK , 0 );
42834318#endif
42844319
4320+ /*
4321+ * Indicate whether set_encoding_key is available
4322+ */
4323+ #ifdef HAVE_MEMCACHED_SET_ENCODING_KEY
4324+ REGISTER_MEMC_CLASS_CONST_BOOL (HAVE_ENCODING , 1 );
4325+ #else
4326+ REGISTER_MEMC_CLASS_CONST_BOOL (HAVE_ENCODING , 0 );
4327+ #endif
4328+
42854329#ifdef HAVE_MEMCACHED_SESSION
42864330 REGISTER_MEMC_CLASS_CONST_BOOL (HAVE_SESSION , 1 );
42874331#else
0 commit comments