docs: ws
[m6w6/libmemcached] / docs / source / libmemcachedutil / memcached_pool.rst
1 Working with memcached pools
2 ============================
3
4 SYNOPSIS
5 --------
6
7 #include <libmemcached/memcached_pool.h>
8 Compile and link with -lmemcachedutil -lmemcached
9
10 .. type:: struct memcached_pool_st memcached_pool_st
11
12 .. function:: memcached_pool_st* memcached_pool(const char *option_string, size_t option_string_length)
13
14 .. function:: memcached_st* memcached_pool_destroy(memcached_pool_st* pool)
15
16 .. function:: memcached_st* memcached_pool_fetch(memcached_pool_st*, struct timespec* relative_time, memcached_return_t* rc)
17 .. versionadded:: 0.53
18 Synonym for memcached_pool_pop
19
20 .. function:: memcached_return_t memcached_pool_release(memcached_pool_st* pool, memcached_st* mmc)
21 .. versionadded:: 0.53
22 Synonym for memcached_pool_push.
23
24 .. function:: memcached_return_t memcached_pool_behavior_set(memcached_pool_st *pool, memcached_behavior_t flag, uint64_t data)
25
26 .. function:: memcached_return_t memcached_pool_behavior_get(memcached_pool_st *pool, memcached_behavior_t flag, uint64_t *value)
27
28 .. function:: memcached_pool_st* memcached_pool_create(memcached_st* mmc, int initial, int max)
29 .. deprecated:: 0.46
30 Use :func:`memcached_pool`
31
32 .. function:: memcached_st* memcached_pool_pop(memcached_pool_st* pool, bool block, memcached_return_t *rc)
33 .. deprecated:: 0.53
34 Use :func:`memcached_pool_fetch`
35
36 .. function:: memcached_return_t memcached_pool_push(memcached_pool_st* pool, memcached_st *mmc)
37 .. deprecated:: 0.53
38 Use :func:`memcached_pool_release`
39
40 DESCRIPTION
41 -----------
42
43 :func:`memcached_pool` is used to create a connection pool of objects you
44 may use to remove the overhead of using memcached_clone for short lived
45 :type:`memcached_st` objects. Please see :doc:`../libmemcached/configuration`
46 for details on the format of the configuration string.
47
48 :func:`memcached_pool_destroy` is used to destroy the connection pool
49 created with :func:`memcached_pool_create` and release all allocated
50 resources. It will return the pointer to the :type:`memcached_st` structure
51 passed as an argument to :func:`memcached_pool_create`, and returns the
52 ownership of the pointer to the caller when created with
53 :func:`memcached_pool_create`, otherwise NULL is returned..
54
55 :func:`memcached_pool_fetch` is used to fetch a connection structure from the
56 connection pool. The relative_time argument specifies if the function should
57 block and wait for a connection structure to be available if we try
58 to exceed the maximum size. You need to specify time in relative time.
59
60 :func:`memcached_pool_release` is used to return a connection structure back
61 to the pool.
62
63 :func:`memcached_pool_behavior_get` and :func:`memcached_pool_behavior_set`
64 is used to get/set behavior flags on all connections in the pool.
65
66 Both :func:`memcached_pool_release` and :func:`memcached_pool_fetch` are
67 thread safe.
68
69 RETURN
70 ------
71
72 :func:`memcached_pool_destroy` returns the pointer (and ownership) to the
73 :type:`memcached_st` structure used to create the pool. If connections are in
74 use it returns NULL.
75
76 :func:`memcached_pool_pop` returns a pointer to a :type:`memcached_st`
77 structure from the pool (or NULL if an allocation cannot be satisfied).
78
79 :func:`memcached_pool_release` returns `MEMCACHED_SUCCESS` upon success.
80
81 :func:`memcached_pool_behavior_get` and :func:`memcached_pool_behavior_get`
82 returns `MEMCACHED_SUCCESS` upon success.
83
84 If any methods returns MEMCACHED_IN_PROGRESS then a lock on the pool could not
85 be obtained. If any of the parameters passed to any of these functions is
86 invalid, MEMCACHED_INVALID_ARGUMENTS will be returned.
87
88 memcached_pool_fetch may return MEMCACHED_TIMEOUT if a timeout occurs while
89 waiting for a free memcached_st. MEMCACHED_NOTFOUND if no memcached_st was
90 available.
91
92 SEE ALSO
93 --------
94
95 .. only:: man
96
97 :manpage:`memcached(1)`
98 :manpage:`libmemcached(3)`
99 :manpage:`libmemcached_configuration(3)`
100 :manpage:`memcached_strerror(3)`
101
102 .. only:: html
103
104 * :manpage:`memcached(1)`
105 * :doc:`../libmemcached`
106 * :doc:`../libmemcached/configuration`
107 * :doc:`../libmemcached/memcached_strerror`