Skip to content

Commit b73b810

Browse files
committed
Support for binary protocol in sessions.
(patch from [email protected])
1 parent 766a16d commit b73b810

File tree

4 files changed

+14
-0
lines changed

4 files changed

+14
-0
lines changed

memcached.ini

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ memcached.sess_lock_wait = 150000
1717
; the default value is "memc.sess.key."
1818
memcached.sess_prefix = "memc.sess.key."
1919

20+
; memcached session binary mode
21+
memcached.sess_binary = Off
22+
2023
; Set the compression type
2124
; valid values are: fastlz, zlib
2225
; the default is fastlz

php_memcached.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,7 @@ static PHP_INI_MH(OnUpdateSerializer)
281281
PHP_INI_BEGIN()
282282
#ifdef HAVE_MEMCACHED_SESSION
283283
STD_PHP_INI_ENTRY("memcached.sess_locking", "1", PHP_INI_ALL, OnUpdateBool, sess_locking_enabled, zend_php_memcached_globals, php_memcached_globals)
284+
STD_PHP_INI_ENTRY("memcached.sess_binary", "0", PHP_INI_ALL, OnUpdateBool, sess_binary_enabled, zend_php_memcached_globals, php_memcached_globals)
284285
STD_PHP_INI_ENTRY("memcached.sess_lock_wait", "150000", PHP_INI_ALL, OnUpdateLongGEZero,sess_lock_wait, zend_php_memcached_globals, php_memcached_globals)
285286
STD_PHP_INI_ENTRY("memcached.sess_prefix", "memc.sess.key.", PHP_INI_ALL, OnUpdateString, sess_prefix, zend_php_memcached_globals, php_memcached_globals)
286287
#endif
@@ -3017,6 +3018,7 @@ static void php_memc_init_globals(zend_php_memcached_globals *php_memcached_glob
30173018
{
30183019
#ifdef HAVE_MEMCACHED_SESSION
30193020
MEMC_G(sess_locking_enabled) = 1;
3021+
MEMC_G(sess_binary_enabled) = 1;
30203022
MEMC_G(sess_prefix) = NULL;
30213023
MEMC_G(sess_lock_wait) = 0;
30223024
MEMC_G(sess_locked) = 0;

php_memcached.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ ZEND_BEGIN_MODULE_GLOBALS(php_memcached)
7878
#if HAVE_MEMCACHED_SASL
7979
bool use_sasl;
8080
#endif
81+
zend_bool sess_binary_enabled;
8182
ZEND_END_MODULE_GLOBALS(php_memcached)
8283

8384
PHP_MEMCACHED_API zend_class_entry *php_memc_get_ce(void);

php_memcached_session.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,14 @@ PS_OPEN_FUNC(memcached)
188188
}
189189
efree(plist_key);
190190
}
191+
192+
if (MEMC_G(sess_binary_enabled)) {
193+
if (memcached_behavior_set(memc_sess->memc_sess, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL, (uint64_t) 1) == MEMCACHED_FAILURE) {
194+
php_error_docref(NULL TSRMLS_CC, E_WARNING, "failed to set memcached session binary protocol");
195+
return FAILURE;
196+
}
197+
}
198+
191199
return SUCCESS;
192200
}
193201
}

0 commit comments

Comments
 (0)