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