memcached_add.3\\r
memcached_behavior_get.3\\r
memcached_behavior_set.3\\r
+ memcached_clone.3\\r
memcached_create.3\\r
memcached_decrement.3\\r
memcached_delete.3\\r
memcached_free.3: memcached_create.pod\r
pod2man -c "libmemcached" -r "" -s 3 memcached_create.pod > memcached_free.3\r
\r
+memcached_clone.3: memcached_create.pod\r
+ pod2man -c "libmemcached" -r "" -s 3 memcached_create.pod > memcached_clone.3\r
+\r
memcached_set.3: memcached_set.pod\r
pod2man -c "libmemcached" -r "" -s 3 memcached_set.pod > memcached_set.3\r
\r
=head1 SEE ALSO
-memcached(1) libmemcached_examples(3) libmemcached(1) memcat(1) memcp(1) memflush(1) memrm(1) memslap(1) memstat(1) memcached_fetch(3) memcached_replace(3) memcached_server_list_free(3) libmemcached_examples(3) memcached_free(3) memcached_server_add(3) memcached_server_push(3) memcached_add(3) memcached_get(3) memcached_server_count(3) memcached_servers_parse(3) memcached_create(3) memcached_increment(3) memcached_server_list(3) memcached_set(3) memcached_decrement(3) memcached_mget(3) memcached_server_list_append(3) memcached_strerror(3) memcached_delete(3) memcached_quit(3) memcached_server_list_count(3) memcached_verbosity(3)
+memcached(1) libmemcached_examples(3) libmemcached(1) memcat(1) memcp(1) memflush(1) memrm(1) memslap(1) memstat(1) memcached_fetch(3) memcached_replace(3) memcached_server_list_free(3) libmemcached_examples(3) memcached_clone(3) memcached_free(3) memcached_server_add(3) memcached_server_push(3) memcached_add(3) memcached_get(3) memcached_server_count(3) memcached_servers_parse(3) memcached_create(3) memcached_increment(3) memcached_server_list(3) memcached_set(3) memcached_decrement(3) memcached_mget(3) memcached_server_list_append(3) memcached_strerror(3) memcached_delete(3) memcached_quit(3) memcached_server_list_count(3) memcached_verbosity(3)
=cut
void memcached_free (memcached_st *ptr);
+ memcached_st *memcached_clone(memcached_st *clone, memcached_st *source);
+
=head1 DESCRIPTION
memcached_create() is used to create a C<memcached_st> structure that will then
should either pass a statically declared C<memcached_st> to memcached_create() or
a NULL. If a NULL passed in then a structure is allocated for you.
+memcached_clone() is similar to memcached_create(3) but it copies the
+defaults and list of servers from the source C<memcached_st>. If you pass a null as
+the argument for the source to clone, it is the same as a call to memcached_create().
+If the clone argument is NULL a C<memcached_st> will be allocated for you.
+
To clean up memory associated with a C<memcached_st> structure you should pass
it to memcached_free() when you are finished using it. memcached_free() is
the only way to make sure all memory is deallocated when you finish using
memcached_create() returns a pointer to the memcached_st that was created
(or initialized). On an allocation failure, it returns NULL.
+memcached_clone() returns a pointer to the memcached_st that was created
+(or initialized). On an allocation failure, it returns NULL.
+
=head1 HOME
To find out more information please check:
/* Public API */
memcached_st *memcached_create(memcached_st *ptr);
void memcached_free(memcached_st *ptr);
+memcached_st *memcached_clone(memcached_st *clone, memcached_st *ptr);
memcached_return memcached_delete(memcached_st *ptr, char *key, size_t key_length,
time_t expiration);
else
memset(ptr, 0, sizeof(memcached_st));
}
+
+memcached_st *memcached_clone(memcached_st *clone, memcached_st *ptr)
+{
+ memcached_return rc;
+ memcached_st *new_clone;
+
+ if (ptr == NULL)
+ return memcached_create(clone);
+
+ new_clone= memcached_create(clone);
+
+
+ rc= memcached_server_push(new_clone, ptr->hosts);
+
+ if (rc != MEMCACHED_SUCCESS)
+ {
+ memcached_free(new_clone);
+
+ return NULL;
+ }
+
+
+ new_clone->flags= ptr->flags;
+ new_clone->number_of_hosts= ptr->number_of_hosts;
+ new_clone->send_size= ptr->send_size;
+ new_clone->recv_size= ptr->recv_size;
+
+ return new_clone;
+}
%{_mandir}/man3/memcached_add.3.gz
%{_mandir}/man3/memcached_behavior_get.3.gz
%{_mandir}/man3/memcached_behavior_set.3.gz
+%{_mandir}/man3/memcached_clone.3.gz
%{_mandir}/man3/memcached_create.3.gz
%{_mandir}/man3/memcached_decrement.3.gz
%{_mandir}/man3/memcached_delete.3.gz
memcached_free(memc);
}
+void clone_test(memcached_st *memc)
+{
+ /* All null? */
+ {
+ memcached_st *clone;
+ clone= memcached_clone(NULL, NULL);
+ assert(clone);
+ memcached_free(clone);
+ }
+
+ /* Can we init from null? */
+ {
+ memcached_st *clone;
+ clone= memcached_clone(NULL, memc);
+ assert(clone);
+ memcached_free(clone);
+ }
+
+ /* Can we init from struct? */
+ {
+ memcached_st declared_clone;
+ memcached_st *clone;
+ clone= memcached_clone(&declared_clone, NULL);
+ assert(clone);
+ memcached_free(clone);
+ }
+
+ /* Can we init from struct? */
+ {
+ memcached_st declared_clone;
+ memcached_st *clone;
+ clone= memcached_clone(&declared_clone, memc);
+ assert(clone);
+ memcached_free(clone);
+ }
+}
+
void connection_test(memcached_st *memc)
{
memcached_return rc;
{"flush", 0, flush_test },
{"init", 0, init_test },
{"allocation", 0, allocation_test },
+ {"clone_test", 0, clone_test },
{"error", 0, error_test },
{"set", 0, set_test },
{"set2", 0, set_test2 },