~ubuntu-branches/ubuntu/vivid/php-memcache/vivid

« back to all changes in this revision

Viewing changes to memcache-3.0.6/README

  • Committer: Package Import Robot
  • Author(s): Sergey B Kirpichev
  • Date: 2012-10-13 20:12:02 UTC
  • mfrom: (1.1.7) (2.1.14 sid)
  • Revision ID: package-import@ubuntu.com-20121013201202-o0slp7ir75l050xr
* Add VCS-* fields
* Imported Upstream version 3.0.7
* Drop unnecessary fix_paths_m4.patch

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
memcached module for PHP
2
 
------------------------
3
 
This module requires zlib library, used for on-the-fly data (de)compression.
4
 
Also, you'll need memcached to use it =)
5
 
 
6
 
The memcached website is here:
7
 
    http://www.danga.com/memcached/
8
 
 
9
 
You will probably need libevent to install memcached:
10
 
You can download it here: http://www.monkey.org/~provos/libevent/
11
 
 
12
 
 
13
 
New API in 3.0
14
 
------------------------
15
 
 
16
 
 Version 3 introduces a new class "MemcachePool" which implements the new API, the 
17
 
 old class "Memcache" is still retained (but is deprecated) with the same interface 
18
 
 for backwards compatibility. Please note that you need a new memcached version to
19
 
 use the CAS, default value to increment/decrement, append and prepend, and binary 
20
 
 protocol features.
21
 
 
22
 
 New INI directives are available to allow control over protocol, redundancy and hash
23
 
 strategy selection. These are
24
 
 
25
 
        # The binary protocol results in less traffic and is more efficient
26
 
        # for the client and server to generate/parse
27
 
 
28
 
        memcache.protocol = {ascii, binary}             # default ascii
29
 
 
30
 
        # When enabled the client sends requests to N servers in parallel, resulting in
31
 
        # a somewhat crude reduncancy or mirroring, suitable when used as a session 
32
 
        # storage. 
33
 
        #
34
 
        # If data integrity is of greater importance a real replicating memcached 
35
 
        # backend such as "repcached" (http://sourceforge.net/projects/repcached/) is 
36
 
        # recommended
37
 
 
38
 
        memcache.redundancy = <int>                     # default 1
39
 
        memcache.session_redundancy = <int>             # default 2
40
 
 
41
 
        # Hash strategy and function selection. The consistent hashing strategy
42
 
        # is now the default as it allows servers to be added and removed from
43
 
        # the pool without resulting in all or most keys being re-mapped to 
44
 
        # other server (ie. voiding the cache)
45
 
 
46
 
        memcache.hash_strategy = {standard, consistent} # default consistent
47
 
        memcache.hash_function = {crc32, fnv}                   # default crc32
48
 
        
49
 
        # Compression is enabled by default, the threshold which control the minimum 
50
 
        # string length which triggers compresssion can be changed as
51
 
        
52
 
        memcache.compress_threshold = <int>             # default 20000
53
 
 
54
 
 
55
 
 The directives are used by the MemcachePool constructor so you can instantiate 
56
 
 several pools with different settings by using ini_set() creativly. For example
57
 
 
58
 
        ini_set('memcache.protocol', 'binary');
59
 
 
60
 
        $binarypool = new MemcachePool();
61
 
        $binarypool->addServer(...)
62
 
 
63
 
        ini_set('memcache.protocol', 'ascii');
64
 
        ini_set('memcache.redundancy', '2');
65
 
 
66
 
        $redundantpool = new MemcachePool();
67
 
        $redundantpool->addServer(...)
68
 
 
69
 
        ini_set('memcache.redundancy', '1');
70
 
 
71
 
 
72
 
 The new interface looks like 
73
 
 
74
 
class MemcachePool() {
75
 
        bool connect(string host, int tcp_port = 11211, int udp_port = 0, bool persistent = true, int weight = 1, int timeout = 1, int retry_interval = 15)
76
 
        bool addServer(string host, int tcp_port = 11211, int udp_port = 0, bool persistent = true, int weight = 1, int timeout = 1, int retry_interval = 15, bool status = true)
77
 
        bool setServerParams(string host, int tcp_port = 11211, int timeout = 1, int retry_interval = 15, bool status = true)
78
 
        
79
 
        /**
80
 
         * Supports fetching flags and CAS values
81
 
         */
82
 
        mixed get(mixed key, mixed &flags = null, mixed &cas = null)
83
 
        
84
 
        /**
85
 
         * Supports multi-set, for example
86
 
         *  $memcache->set(array('key1' => 'val1', 'key2' => 'val1'), null, 0, 60)
87
 
         */
88
 
        bool add(mixed key, mixed var = null, int flag = 0, int exptime = 0)
89
 
        bool set(mixed key, mixed var = null, int flag = 0, int exptime = 0)
90
 
        bool replace(mixed key, mixed var = null, int flag = 0, int exptime = 0)
91
 
        
92
 
        /**
93
 
         * Compare-and-Swap, uses the CAS param from MemcachePool::get() 
94
 
         */
95
 
        bool cas(mixed key, mixed var = null, int flag = 0, int exptime = 0, int cas = 0)
96
 
        
97
 
        /**
98
 
         * Prepends/appends a value to an existing one
99
 
         */
100
 
        bool append(mixed key, mixed var = null, int flag = 0, int exptime = 0)
101
 
        bool prepend(mixed key, mixed var = null, int flag = 0, int exptime = 0)
102
 
        
103
 
        /**
104
 
         * Supports multi-key operations, for example
105
 
         *  $memcache->delete(array('key1', 'key2'))
106
 
         */
107
 
        bool delete(mixed key, int exptime = 0)
108
 
 
109
 
        /**
110
 
         * Supports multi-key operations, for example
111
 
         *  $memcache->increment(array('key1', 'key2'), 1, 0, 0)
112
 
         *
113
 
         * The new defval (default value) and exptime (expiration time) are used
114
 
         * if the key doesn't already exist. They must be supplied (even if 0) for
115
 
         * this to be enabled.
116
 
         *
117
 
         * Returns an integer with the new value if key is a string
118
 
         * Returns an array of integers if the key is an array
119
 
         */
120
 
        mixed increment(mixed key, int value = 1, int defval = 0, int exptime = 0)
121
 
        mixed decrement(mixed key, int value = 1, int defval = 0, int exptime = 0)
122
 
        
123
 
        /**
124
 
         * Assigns a pool-specific failure callback which will be called when 
125
 
         * a request fails. May be null in order to disable callbacks. The callback
126
 
         * receive arguments like
127
 
         *
128
 
         *  function mycallback($host, $tcp_port, $udp_port, $error, $errnum)
129
 
         *
130
 
         * Where $host and $error are strings or null, the other params are integers.
131
 
         */
132
 
        bool setFailureCallback(function callback)
133
 
        
134
 
        /**
135
 
         * Locates the server a given would be hashed to
136
 
         * 
137
 
         * Returns a string "hostname:port" on success
138
 
         * Returns false on failure such as invalid key
139
 
         */
140
 
        string findServer(string key)
141
 
}
142
 
 
143
 
 
144
 
Maintainers:
145
 
Mikael Johansson        mikael at synd dot info
146
 
Antony Dovgal           tony2001 at phpclub dot net