the remote connection.
* Added memcached_fetch_execute() method
* Found a bug where memcached_fetch() was not null terminating the result
value.
+ * memcached_behavior() now has the ability to set "buffering" so that
+ data is not automatically flushed.
+ * Behavior change, buffered commands now return MEMCACHED_BUFFERED
0.12 Tue Dec 11 15:20:55 PST 2007
* Updates for consistent hashing
Modify the timeout value that is used by poll(). The default value is -1. An signed int pointer must be passed to memcached_behavior_set() to change this value. For memcached_behavior_get() a signed int value will be cast and returned as the unsigned long long.
+=item MEMCACHED_BUFFERED
+
+Enabling buffered IO causes commands to "buffer" instead of being sent. Any
+action that gets data causes this buffer to be be sent to the remote
+connection. Quiting the connection or closing down the connection will also
+cause the buffered data to be pushed to the remote connection.
=back
MEMCACHED_NO_KEY_PROVIDED,
MEMCACHED_FETCH_NOTFINISHED,
MEMCACHED_TIMEOUT,
+ MEMCACHED_BUFFERED,
MEMCACHED_MAXIMUM_RETURN, /* Always add new error code before */
} memcached_return;
MEMCACHED_BEHAVIOR_SUPPORT_CAS,
MEMCACHED_BEHAVIOR_POLL_TIMEOUT,
MEMCACHED_BEHAVIOR_DISTRIBUTION,
+ MEMCACHED_BEHAVIOR_BUFFER_REQUESTS,
} memcached_behavior;
typedef enum {
MEM_USE_CRC= (1 << 5),
MEM_USE_CACHE_LOOKUPS= (1 << 6),
MEM_SUPPORT_CAS= (1 << 7),
+ MEM_BUFFER_REQUESTS= (1 << 8),
} memcached_flags;
/* Hashing algo */
break;
case MEMCACHED_BEHAVIOR_NO_BLOCK:
set_behavior_flag(ptr, MEM_NO_BLOCK, data);
+ case MEMCACHED_BEHAVIOR_BUFFER_REQUESTS:
+ set_behavior_flag(ptr, MEM_BUFFER_REQUESTS, data);
break;
case MEMCACHED_BEHAVIOR_TCP_NODELAY:
set_behavior_flag(ptr, MEM_TCP_NODELAY, data);
case MEMCACHED_BEHAVIOR_NO_BLOCK:
temp_flag= MEM_NO_BLOCK;
break;
+ case MEMCACHED_BEHAVIOR_BUFFER_REQUESTS:
+ temp_flag= MEM_BUFFER_REQUESTS;
+ break;
case MEMCACHED_BEHAVIOR_TCP_NODELAY:
temp_flag= MEM_TCP_NODELAY;
break;
goto error;
}
- if ((ptr->flags & MEM_NO_BLOCK))
- to_write= 0;
- else
- to_write= 1;
+ to_write= (ptr->flags & MEM_BUFFER_REQUESTS) ? 0 : 1;
rc= memcached_do(ptr, server_key, buffer, send_length, to_write);
if (rc != MEMCACHED_SUCCESS)
goto error;
- if ((ptr->flags & MEM_NO_BLOCK))
+ if ((ptr->flags & MEM_BUFFER_REQUESTS))
{
- rc= MEMCACHED_SUCCESS;
+ rc= MEMCACHED_BUFFERED;
}
else
{
(void)memcached_do(ptr, server_key, buffer, send_length, 0);
}
- for (x= 0; x < ptr->number_of_hosts; x++)
- {
- if (memcached_server_response_count(ptr, x))
- {
- /* We need to do something about non-connnected hosts in the future */
- if ((memcached_io_write(ptr, x, NULL, 0, 1)) == -1)
- {
- rc= MEMCACHED_SOME_ERRORS;
- }
- }
- }
-
- LIBMEMCACHED_MEMCACHED_DELETE_END();
- return rc;
+ return MEMCACHED_BUFFERED;
}
goto error;
}
- if ((ptr->flags & MEM_NO_BLOCK) && verb == SET_OP)
+ if ((ptr->flags & MEM_BUFFER_REQUESTS) && verb == SET_OP)
to_write= 0;
else
to_write= 1;
}
if (to_write == 0)
- rc= MEMCACHED_SUCCESS;
- else
- rc= memcached_response(ptr, buffer, MEMCACHED_DEFAULT_COMMAND_SIZE, NULL, server_key);
+ return MEMCACHED_BUFFERED;
+
+ rc= memcached_response(ptr, buffer, MEMCACHED_DEFAULT_COMMAND_SIZE, NULL, server_key);
if (rc == MEMCACHED_STORED)
return MEMCACHED_SUCCESS;
return "FETCH WAS NOT COMPLETED";
case MEMCACHED_NO_KEY_PROVIDED:
return "A KEY LENGTH OF ZERO WAS PROVIDED";
+ case MEMCACHED_BUFFERED:
+ return "ACTION QUEUED";
case MEMCACHED_TIMEOUT:
return "A TIMEOUT OCCURRED";
case MEMCACHED_MAXIMUM_RETURN:
return 0;
}
+uint8_t generate_buffer_data(memcached_st *memc)
+{
+ int latch= 0;
+
+ latch= 1;
+ memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_BUFFER_REQUESTS, &latch);
+ generate_data(memc);
+
+ return 0;
+}
+
#ifdef NOT_DONE
uint8_t mset_data(memcached_st *memc)
{
return 0;
}
+uint8_t delete_buffer_generate(memcached_st *memc)
+{
+ int latch= 0;
+ unsigned int x;
+
+ latch= 1;
+ memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_BUFFER_REQUESTS, &latch);
+
+ for (x= 0; x < GLOBAL_COUNT; x++)
+ {
+ (void)memcached_delete(memc, global_keys[x], global_keys_length[x], (time_t)0);
+ }
+
+ return 0;
+}
+
uint8_t mdelete_generate(memcached_st *memc)
{
memcached_return rc;
{"generate_data", 0, generate_data },
{"get_read", 0, get_read },
{"delete_generate", 0, delete_generate },
+ {"generate_buffer_data", 0, generate_buffer_data },
+ {"delete_buffer", 0, delete_buffer_generate},
{"generate_data", 0, generate_data },
{"mget_read", 0, mget_read },
{"mget_read_result", 0, mget_read_result },