@@ -111,6 +111,7 @@ typedef unsigned long int uint32_t;
111111#define MEMC_OPT_PREFIX_KEY -1002
112112#define MEMC_OPT_SERIALIZER -1003
113113#define MEMC_OPT_COMPRESSION_TYPE -1004
114+ #define MEMC_OPT_STORE_RETRY_COUNT -1005
114115
115116/****************************************
116117 Custom result codes
@@ -202,6 +203,7 @@ typedef struct {
202203#if HAVE_MEMCACHED_SASL
203204 zend_bool has_sasl_data ;
204205#endif
206+ long store_retry_count ;
205207 } * obj ;
206208
207209 zend_bool is_persistent ;
@@ -315,6 +317,7 @@ PHP_INI_BEGIN()
315317#if HAVE_MEMCACHED_SASL
316318 STD_PHP_INI_ENTRY ("memcached.use_sasl" , "0" , PHP_INI_SYSTEM , OnUpdateBool , use_sasl , zend_php_memcached_globals , php_memcached_globals )
317319#endif
320+ STD_PHP_INI_ENTRY ("memcached.store_retry_count" , "2" , PHP_INI_ALL , OnUpdateLong , store_retry_count , zend_php_memcached_globals , php_memcached_globals )
318321PHP_INI_END ()
319322/* }}} */
320323
@@ -465,6 +468,7 @@ static PHP_METHOD(Memcached, __construct)
465468 m_obj -> serializer = MEMC_G (serializer );
466469 m_obj -> compression_type = MEMC_G (compression_type_real );
467470 m_obj -> compression = 1 ;
471+ m_obj -> store_retry_count = MEMC_G (store_retry_count );
468472
469473 i_obj -> obj = m_obj ;
470474 i_obj -> is_pristine = 1 ;
@@ -1142,7 +1146,7 @@ PHP_METHOD(Memcached, setMultiByKey)
11421146/* }}} */
11431147
11441148#define PHP_MEMC_FAILOVER_RETRY \
1145- if (!by_key && retry < 2 ) { \
1149+ if (!by_key && retry < m_obj->store_retry_count ) { \
11461150 switch (i_obj->rescode) { \
11471151 case MEMCACHED_HOST_LOOKUP_FAILURE: \
11481152 case MEMCACHED_CONNECTION_FAILURE: \
@@ -2278,6 +2282,10 @@ static PHP_METHOD(Memcached, getOption)
22782282 RETURN_LONG ((long )m_obj -> serializer );
22792283 break ;
22802284
2285+ case MEMC_OPT_STORE_RETRY_COUNT :
2286+ RETURN_LONG ((long )m_obj -> store_retry_count );
2287+ break ;
2288+
22812289 case MEMCACHED_BEHAVIOR_SOCKET_SEND_SIZE :
22822290 case MEMCACHED_BEHAVIOR_SOCKET_RECV_SIZE :
22832291 if (memcached_server_count (m_obj -> memc ) == 0 ) {
@@ -2400,6 +2408,11 @@ static int php_memc_set_option(php_memc_t *i_obj, long option, zval *value TSRML
24002408 break ;
24012409 }
24022410
2411+ case MEMC_OPT_STORE_RETRY_COUNT :
2412+ convert_to_long (value );
2413+ m_obj -> store_retry_count = Z_LVAL_P (value );
2414+ break ;
2415+
24032416 default :
24042417 /*
24052418 * Assume that it's a libmemcached behavior option.
@@ -3189,6 +3202,7 @@ static void php_memc_init_globals(zend_php_memcached_globals *php_memcached_glob
31893202#if HAVE_MEMCACHED_SASL
31903203 MEMC_G (use_sasl ) = 0 ;
31913204#endif
3205+ MEMC_G (store_retry_count ) = 2 ;
31923206}
31933207
31943208static void php_memc_destroy_globals (zend_php_memcached_globals * php_memcached_globals_p TSRMLS_DC )
@@ -3797,6 +3811,7 @@ static void php_memc_register_constants(INIT_FUNC_ARGS)
37973811 REGISTER_MEMC_CLASS_CONST_LONG (OPT_COMPRESSION_TYPE , MEMC_OPT_COMPRESSION_TYPE );
37983812 REGISTER_MEMC_CLASS_CONST_LONG (OPT_PREFIX_KEY , MEMC_OPT_PREFIX_KEY );
37993813 REGISTER_MEMC_CLASS_CONST_LONG (OPT_SERIALIZER , MEMC_OPT_SERIALIZER );
3814+ REGISTER_MEMC_CLASS_CONST_LONG (OPT_STORE_RETRY_COUNT , MEMC_OPT_STORE_RETRY_COUNT );
38003815
38013816 /*
38023817 * Indicate whether igbinary serializer is available
0 commit comments