memcached 0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data.tar.gz.sig +2 -0
- data/CHANGELOG +2 -0
- data/LICENSE +184 -0
- data/Manifest +19 -0
- data/README +51 -0
- data/ext/extconf.rb +16 -0
- data/ext/libmemcached.h +425 -0
- data/ext/libmemcached.i +96 -0
- data/ext/libmemcached_wrap.c +9159 -0
- data/lib/memcached.rb +6 -0
- data/lib/memcached/behaviors.rb +46 -0
- data/lib/memcached/exceptions.rb +30 -0
- data/lib/memcached/integer.rb +6 -0
- data/lib/memcached/memcached.rb +218 -0
- data/memcached.gemspec +38 -0
- data/test/benchmark/benchmark_test.rb +42 -0
- data/test/setup.rb +14 -0
- data/test/teardown.rb +0 -0
- data/test/test_helper.rb +19 -0
- data/test/unit/binding_test.rb +8 -0
- data/test/unit/memcached_test.rb +325 -0
- metadata +97 -0
- metadata.gz.sig +0 -0
data.tar.gz.sig
ADDED
data/CHANGELOG
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,184 @@
|
|
1
|
+
Academic Free License (AFL) v. 3.0
|
2
|
+
|
3
|
+
This Academic Free License (the "License") applies to any original work
|
4
|
+
of authorship (the "Original Work") whose owner (the "Licensor") has
|
5
|
+
placed the following licensing notice adjacent to the copyright notice
|
6
|
+
for the Original Work:
|
7
|
+
|
8
|
+
Licensed under the Academic Free License version 3.0
|
9
|
+
|
10
|
+
1) Grant of Copyright License. Licensor grants You a worldwide,
|
11
|
+
royalty-free, non-exclusive, sublicensable license, for the duration of
|
12
|
+
the copyright, to do the following:
|
13
|
+
|
14
|
+
a) to reproduce the Original Work in copies, either alone or as part of
|
15
|
+
a collective work;
|
16
|
+
|
17
|
+
b) to translate, adapt, alter, transform, modify, or arrange the
|
18
|
+
Original Work, thereby creating derivative works ("Derivative Works")
|
19
|
+
based upon the Original Work;
|
20
|
+
|
21
|
+
c) to distribute or communicate copies of the Original Work and
|
22
|
+
Derivative Works to the public, under any license of your choice that
|
23
|
+
does not contradict the terms and conditions, including Licensor's
|
24
|
+
reserved rights and remedies, in this Academic Free License;
|
25
|
+
|
26
|
+
d) to perform the Original Work publicly; and
|
27
|
+
|
28
|
+
e) to display the Original Work publicly.
|
29
|
+
|
30
|
+
2) Grant of Patent License. Licensor grants You a worldwide,
|
31
|
+
royalty-free, non-exclusive, sublicensable license, under patent claims
|
32
|
+
owned or controlled by the Licensor that are embodied in the Original
|
33
|
+
Work as furnished by the Licensor, for the duration of the patents, to
|
34
|
+
make, use, sell, offer for sale, have made, and import the Original Work
|
35
|
+
and Derivative Works.
|
36
|
+
|
37
|
+
3) Grant of Source Code License. The term "Source Code" means the
|
38
|
+
preferred form of the Original Work for making modifications to it and
|
39
|
+
all available documentation describing how to modify the Original Work.
|
40
|
+
Licensor agrees to provide a machine-readable copy of the Source Code of
|
41
|
+
the Original Work along with each copy of the Original Work that
|
42
|
+
Licensor distributes. Licensor reserves the right to satisfy this
|
43
|
+
obligation by placing a machine-readable copy of the Source Code in an
|
44
|
+
information repository reasonably calculated to permit inexpensive and
|
45
|
+
convenient access by You for as long as Licensor continues to distribute
|
46
|
+
the Original Work.
|
47
|
+
|
48
|
+
4) Exclusions From License Grant. Neither the names of Licensor, nor the
|
49
|
+
names of any contributors to the Original Work, nor any of their
|
50
|
+
trademarks or service marks, may be used to endorse or promote products
|
51
|
+
derived from this Original Work without express prior permission of the
|
52
|
+
Licensor. Except as expressly stated herein, nothing in this License
|
53
|
+
grants any license to Licensor's trademarks, copyrights, patents, trade
|
54
|
+
secrets or any other intellectual property. No patent license is granted
|
55
|
+
to make, use, sell, offer for sale, have made, or import embodiments of
|
56
|
+
any patent claims other than the licensed claims defined in Section 2.
|
57
|
+
No license is granted to the trademarks of Licensor even if such marks
|
58
|
+
are included in the Original Work. Nothing in this License shall be
|
59
|
+
interpreted to prohibit Licensor from licensing under terms different
|
60
|
+
from this License any Original Work that Licensor otherwise would have a
|
61
|
+
right to license.
|
62
|
+
|
63
|
+
5) External Deployment. The term "External Deployment" means the use,
|
64
|
+
distribution, or communication of the Original Work or Derivative Works
|
65
|
+
in any way such that the Original Work or Derivative Works may be used
|
66
|
+
by anyone other than You, whether those works are distributed or
|
67
|
+
communicated to those persons or made available as an application
|
68
|
+
intended for use over a network. As an express condition for the grants
|
69
|
+
of license hereunder, You must treat any External Deployment by You of
|
70
|
+
the Original Work or a Derivative Work as a distribution under section
|
71
|
+
1(c).
|
72
|
+
|
73
|
+
6) Attribution Rights. You must retain, in the Source Code of any
|
74
|
+
Derivative Works that You create, all copyright, patent, or trademark
|
75
|
+
notices from the Source Code of the Original Work, as well as any
|
76
|
+
notices of licensing and any descriptive text identified therein as an
|
77
|
+
"Attribution Notice." You must cause the Source Code for any Derivative
|
78
|
+
Works that You create to carry a prominent Attribution Notice reasonably
|
79
|
+
calculated to inform recipients that You have modified the Original
|
80
|
+
Work.
|
81
|
+
|
82
|
+
7) Warranty of Provenance and Disclaimer of Warranty. Licensor warrants
|
83
|
+
that the copyright in and to the Original Work and the patent rights
|
84
|
+
granted herein by Licensor are owned by the Licensor or are sublicensed
|
85
|
+
to You under the terms of this License with the permission of the
|
86
|
+
contributor(s) of those copyrights and patent rights. Except as
|
87
|
+
expressly stated in the immediately preceding sentence, the Original
|
88
|
+
Work is provided under this License on an "AS IS" BASIS and WITHOUT
|
89
|
+
WARRANTY, either express or implied, including, without limitation, the
|
90
|
+
warranties of non-infringement, merchantability or fitness for a
|
91
|
+
particular purpose. THE ENTIRE RISK AS TO THE QUALITY OF THE ORIGINAL
|
92
|
+
WORK IS WITH YOU. This DISCLAIMER OF WARRANTY constitutes an essential
|
93
|
+
part of this License. No license to the Original Work is granted by this
|
94
|
+
License except under this disclaimer.
|
95
|
+
|
96
|
+
8) Limitation of Liability. Under no circumstances and under no legal
|
97
|
+
theory, whether in tort (including negligence), contract, or otherwise,
|
98
|
+
shall the Licensor be liable to anyone for any indirect, special,
|
99
|
+
incidental, or consequential damages of any character arising as a
|
100
|
+
result of this License or the use of the Original Work including,
|
101
|
+
without limitation, damages for loss of goodwill, work stoppage,
|
102
|
+
computer failure or malfunction, or any and all other commercial damages
|
103
|
+
or losses. This limitation of liability shall not apply to the extent
|
104
|
+
applicable law prohibits such limitation.
|
105
|
+
|
106
|
+
9) Acceptance and Termination. If, at any time, You expressly assented
|
107
|
+
to this License, that assent indicates your clear and irrevocable
|
108
|
+
acceptance of this License and all of its terms and conditions. If You
|
109
|
+
distribute or communicate copies of the Original Work or a Derivative
|
110
|
+
Work, You must make a reasonable effort under the circumstances to
|
111
|
+
obtain the express assent of recipients to the terms of this License.
|
112
|
+
This License conditions your rights to undertake the activities listed
|
113
|
+
in Section 1, including your right to create Derivative Works based upon
|
114
|
+
the Original Work, and doing so without honoring these terms and
|
115
|
+
conditions is prohibited by copyright law and international treaty.
|
116
|
+
Nothing in this License is intended to affect copyright exceptions and
|
117
|
+
limitations (including "fair use" or "fair dealing"). This License shall
|
118
|
+
terminate immediately and You may no longer exercise any of the rights
|
119
|
+
granted to You by this License upon your failure to honor the conditions
|
120
|
+
in Section 1(c).
|
121
|
+
|
122
|
+
10) Termination for Patent Action. This License shall terminate
|
123
|
+
automatically and You may no longer exercise any of the rights granted
|
124
|
+
to You by this License as of the date You commence an action, including
|
125
|
+
a cross-claim or counterclaim, against Licensor or any licensee alleging
|
126
|
+
that the Original Work infringes a patent. This termination provision
|
127
|
+
shall not apply for an action alleging patent infringement by
|
128
|
+
combinations of the Original Work with other software or hardware.
|
129
|
+
|
130
|
+
11) Jurisdiction, Venue and Governing Law. Any action or suit relating
|
131
|
+
to this License may be brought only in the courts of a jurisdiction
|
132
|
+
wherein the Licensor resides or in which Licensor conducts its primary
|
133
|
+
business, and under the laws of that jurisdiction excluding its
|
134
|
+
conflict-of-law provisions. The application of the United Nations
|
135
|
+
Convention on Contracts for the International Sale of Goods is expressly
|
136
|
+
excluded. Any use of the Original Work outside the scope of this License
|
137
|
+
or after its termination shall be subject to the requirements and
|
138
|
+
penalties of copyright or patent law in the appropriate jurisdiction.
|
139
|
+
This section shall survive the termination of this License.
|
140
|
+
|
141
|
+
12) Attorneys' Fees. In any action to enforce the terms of this License
|
142
|
+
or seeking damages relating thereto, the prevailing party shall be
|
143
|
+
entitled to recover its costs and expenses, including, without
|
144
|
+
limitation, reasonable attorneys' fees and costs incurred in connection
|
145
|
+
with such action, including any appeal of such action. This section
|
146
|
+
shall survive the termination of this License.
|
147
|
+
|
148
|
+
13) Miscellaneous. If any provision of this License is held to be
|
149
|
+
unenforceable, such provision shall be reformed only to the extent
|
150
|
+
necessary to make it enforceable.
|
151
|
+
|
152
|
+
14) Definition of "You" in This License. "You" throughout this License,
|
153
|
+
whether in upper or lower case, means an individual or a legal entity
|
154
|
+
exercising rights under, and complying with all of the terms of, this
|
155
|
+
License. For legal entities, "You" includes any entity that controls, is
|
156
|
+
controlled by, or is under common control with you. For purposes of this
|
157
|
+
definition, "control" means (i) the power, direct or indirect, to cause
|
158
|
+
the direction or management of such entity, whether by contract or
|
159
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
160
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
161
|
+
|
162
|
+
15) Right to Use. You may use the Original Work in all ways not
|
163
|
+
otherwise restricted or conditioned by this License or by law, and
|
164
|
+
Licensor promises not to interfere with or be responsible for such uses
|
165
|
+
by You.
|
166
|
+
|
167
|
+
16) Modification of This License. This License is Copyright (c) 2005
|
168
|
+
Lawrence Rosen. Permission is granted to copy, distribute, or
|
169
|
+
communicate this License without modification. Nothing in this License
|
170
|
+
permits You to modify this License as applied to the Original Work or to
|
171
|
+
Derivative Works. However, You may modify the text of this License and
|
172
|
+
copy, distribute or communicate your modified version (the "Modified
|
173
|
+
License") and apply it to other original works of authorship subject to
|
174
|
+
the following conditions: (i) You may not indicate in any way that your
|
175
|
+
Modified License is the "Academic Free License" or "AFL" and you may not
|
176
|
+
use those names in the name of your Modified License; (ii) You must
|
177
|
+
replace the notice specified in the first paragraph above with the
|
178
|
+
notice "Licensed under <insert your license name here>" or with a notice
|
179
|
+
of your own that is not confusingly similar to the notice in this
|
180
|
+
License; and (iii) You may not claim that your original works are open
|
181
|
+
source software unless your Modified License has been approved by Open
|
182
|
+
Source Initiative (OSI) and You comply with its license review and
|
183
|
+
certification process.
|
184
|
+
|
data/Manifest
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
CHANGELOG
|
2
|
+
ext/extconf.rb
|
3
|
+
ext/libmemcached.h
|
4
|
+
ext/libmemcached.i
|
5
|
+
ext/libmemcached_wrap.c
|
6
|
+
lib/memcached/behaviors.rb
|
7
|
+
lib/memcached/exceptions.rb
|
8
|
+
lib/memcached/integer.rb
|
9
|
+
lib/memcached/memcached.rb
|
10
|
+
lib/memcached.rb
|
11
|
+
LICENSE
|
12
|
+
Manifest
|
13
|
+
README
|
14
|
+
test/benchmark/benchmark_test.rb
|
15
|
+
test/setup.rb
|
16
|
+
test/teardown.rb
|
17
|
+
test/test_helper.rb
|
18
|
+
test/unit/binding_test.rb
|
19
|
+
test/unit/memcached_test.rb
|
data/README
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
|
2
|
+
memcached
|
3
|
+
|
4
|
+
An interface to the libmemcached C client.
|
5
|
+
|
6
|
+
== License
|
7
|
+
|
8
|
+
Copyright 2008 Cloudburst, LLC. Licensed under the AFL 3. See the included LICENSE file. Portions copyright 2008 TangentOrg, Brian Aker, licensed under the BSD license, and used with permission.
|
9
|
+
|
10
|
+
The public certificate for the gem is here[http://rubyforge.org/frs/download.php/25331/evan_weaver-original-public_cert.pem].
|
11
|
+
|
12
|
+
If you like this software, please {make a donation}[http://blog.evanweaver.com/donate/], or {recommend Evan}[http://www.workingwithrails.com/person/7739-evan-weaver] at Working with Rails.
|
13
|
+
|
14
|
+
== Status
|
15
|
+
|
16
|
+
Very new. Risky in production.
|
17
|
+
|
18
|
+
== Features
|
19
|
+
|
20
|
+
* clean API
|
21
|
+
* robust access to all memcached features
|
22
|
+
* multiple hashing modes, including consistent hashing
|
23
|
+
* ludicrous speed, including optional non-blocking IO
|
24
|
+
|
25
|
+
== Requirements
|
26
|
+
|
27
|
+
* {libmemcached 0.13}[http://tangent.org/552/libmemcached.html]
|
28
|
+
|
29
|
+
Other versions of libmemcached are not supported.
|
30
|
+
|
31
|
+
Extract the tarball, then for Linux, run:
|
32
|
+
./configure
|
33
|
+
make && sudo make install
|
34
|
+
|
35
|
+
For OS X/MacPorts, run:
|
36
|
+
./configure --prefix=/opt/local
|
37
|
+
make && sudo make install
|
38
|
+
|
39
|
+
== Usage
|
40
|
+
|
41
|
+
Whatever!
|
42
|
+
|
43
|
+
== Reporting problems
|
44
|
+
|
45
|
+
The support forum is here[http://rubyforge.org/forum/forum.php?forum_id=20894].
|
46
|
+
|
47
|
+
Patches and contributions are very welcome. Please note that contributors are required to assign copyright for their additions to Cloudburst, LLC.
|
48
|
+
|
49
|
+
== Further resources
|
50
|
+
|
51
|
+
Whatever!
|
data/ext/extconf.rb
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
|
2
|
+
require 'mkmf'
|
3
|
+
|
4
|
+
if ENV['SWIG']
|
5
|
+
puts "running SWIG"
|
6
|
+
$stdout.write `swig -I/opt/local/include -ruby -autorename libmemcached.i`
|
7
|
+
end
|
8
|
+
|
9
|
+
if ENV['DEBUG']
|
10
|
+
puts "setting debug flags"
|
11
|
+
$CFLAGS << " -ggdb -DHAVE_DEBUG"
|
12
|
+
end
|
13
|
+
|
14
|
+
dir_config 'libmemcached'
|
15
|
+
find_library 'memcached', 'memcached_server_add'
|
16
|
+
create_makefile 'libmemcached'
|
data/ext/libmemcached.h
ADDED
@@ -0,0 +1,425 @@
|
|
1
|
+
/*
|
2
|
+
* Summary: interface for memcached server
|
3
|
+
* Description: main include file for libmemcached
|
4
|
+
*
|
5
|
+
* Copy: See Copyright for the status of this software.
|
6
|
+
*
|
7
|
+
* Author: Brian Aker
|
8
|
+
*/
|
9
|
+
|
10
|
+
#ifndef __MEMCACHED_H__
|
11
|
+
#define __MEMCACHED_H__
|
12
|
+
|
13
|
+
#include <stdlib.h>
|
14
|
+
#include <inttypes.h>
|
15
|
+
#include <sys/types.h>
|
16
|
+
#include <netinet/in.h>
|
17
|
+
|
18
|
+
#ifdef __cplusplus
|
19
|
+
extern "C" {
|
20
|
+
#endif
|
21
|
+
|
22
|
+
typedef struct memcached_st memcached_st;
|
23
|
+
typedef struct memcached_stat_st memcached_stat_st;
|
24
|
+
typedef struct memcached_result_st memcached_result_st;
|
25
|
+
typedef struct memcached_string_st memcached_string_st;
|
26
|
+
typedef struct memcached_server_st memcached_server_st;
|
27
|
+
|
28
|
+
#define MEMCACHED_VERSION_STRING 12
|
29
|
+
#define MEMCACHED_DEFAULT_PORT 11211
|
30
|
+
#define MEMCACHED_DEFAULT_COMMAND_SIZE 350
|
31
|
+
#define SMALL_STRING_LEN 1024
|
32
|
+
#define HUGE_STRING_LEN 8196
|
33
|
+
#define MEMCACHED_MAX_KEY 251 /* We add one to have it null terminated */
|
34
|
+
#define MEMCACHED_MAX_BUFFER HUGE_STRING_LEN
|
35
|
+
#define MEMCACHED_MAX_HOST_LENGTH 64
|
36
|
+
#define MEMCACHED_WHEEL_SIZE 1024
|
37
|
+
#define MEMCACHED_STRIDE 4
|
38
|
+
#define MEMCACHED_DEFAULT_TIMEOUT INT32_MAX
|
39
|
+
|
40
|
+
typedef enum {
|
41
|
+
MEMCACHED_SUCCESS,
|
42
|
+
MEMCACHED_FAILURE,
|
43
|
+
MEMCACHED_HOST_LOOKUP_FAILURE,
|
44
|
+
MEMCACHED_CONNECTION_FAILURE,
|
45
|
+
MEMCACHED_CONNECTION_BIND_FAILURE,
|
46
|
+
MEMCACHED_WRITE_FAILURE,
|
47
|
+
MEMCACHED_READ_FAILURE,
|
48
|
+
MEMCACHED_UNKNOWN_READ_FAILURE,
|
49
|
+
MEMCACHED_PROTOCOL_ERROR,
|
50
|
+
MEMCACHED_CLIENT_ERROR,
|
51
|
+
MEMCACHED_SERVER_ERROR,
|
52
|
+
MEMCACHED_CONNECTION_SOCKET_CREATE_FAILURE,
|
53
|
+
MEMCACHED_DATA_EXISTS,
|
54
|
+
MEMCACHED_DATA_DOES_NOT_EXIST,
|
55
|
+
MEMCACHED_NOTSTORED,
|
56
|
+
MEMCACHED_STORED,
|
57
|
+
MEMCACHED_NOTFOUND,
|
58
|
+
MEMCACHED_MEMORY_ALLOCATION_FAILURE,
|
59
|
+
MEMCACHED_PARTIAL_READ,
|
60
|
+
MEMCACHED_SOME_ERRORS,
|
61
|
+
MEMCACHED_NO_SERVERS,
|
62
|
+
MEMCACHED_END,
|
63
|
+
MEMCACHED_DELETED,
|
64
|
+
MEMCACHED_VALUE,
|
65
|
+
MEMCACHED_STAT,
|
66
|
+
MEMCACHED_ERRNO,
|
67
|
+
MEMCACHED_FAIL_UNIX_SOCKET,
|
68
|
+
MEMCACHED_NOT_SUPPORTED,
|
69
|
+
MEMCACHED_NO_KEY_PROVIDED,
|
70
|
+
MEMCACHED_FETCH_NOTFINISHED,
|
71
|
+
MEMCACHED_TIMEOUT,
|
72
|
+
MEMCACHED_BUFFERED,
|
73
|
+
MEMCACHED_MAXIMUM_RETURN, /* Always add new error code before */
|
74
|
+
} memcached_return;
|
75
|
+
|
76
|
+
typedef enum {
|
77
|
+
MEMCACHED_DISTRIBUTION_MODULA,
|
78
|
+
MEMCACHED_DISTRIBUTION_CONSISTENT,
|
79
|
+
} memcached_server_distribution;
|
80
|
+
|
81
|
+
typedef enum {
|
82
|
+
MEMCACHED_BEHAVIOR_NO_BLOCK,
|
83
|
+
MEMCACHED_BEHAVIOR_TCP_NODELAY,
|
84
|
+
MEMCACHED_BEHAVIOR_HASH,
|
85
|
+
MEMCACHED_BEHAVIOR_KETAMA,
|
86
|
+
MEMCACHED_BEHAVIOR_SOCKET_SEND_SIZE,
|
87
|
+
MEMCACHED_BEHAVIOR_SOCKET_RECV_SIZE,
|
88
|
+
MEMCACHED_BEHAVIOR_CACHE_LOOKUPS,
|
89
|
+
MEMCACHED_BEHAVIOR_SUPPORT_CAS,
|
90
|
+
MEMCACHED_BEHAVIOR_POLL_TIMEOUT,
|
91
|
+
MEMCACHED_BEHAVIOR_DISTRIBUTION,
|
92
|
+
MEMCACHED_BEHAVIOR_BUFFER_REQUESTS,
|
93
|
+
MEMCACHED_BEHAVIOR_USER_DATA,
|
94
|
+
} memcached_behavior;
|
95
|
+
|
96
|
+
typedef enum {
|
97
|
+
MEMCACHED_HASH_DEFAULT= 0,
|
98
|
+
MEMCACHED_HASH_MD5,
|
99
|
+
MEMCACHED_HASH_CRC,
|
100
|
+
MEMCACHED_HASH_FNV1_64,
|
101
|
+
MEMCACHED_HASH_FNV1A_64,
|
102
|
+
MEMCACHED_HASH_FNV1_32,
|
103
|
+
MEMCACHED_HASH_FNV1A_32,
|
104
|
+
MEMCACHED_HASH_KETAMA,
|
105
|
+
MEMCACHED_HASH_HSIEH,
|
106
|
+
} memcached_hash;
|
107
|
+
|
108
|
+
typedef enum {
|
109
|
+
MEMCACHED_CONNECTION_UNKNOWN,
|
110
|
+
MEMCACHED_CONNECTION_TCP,
|
111
|
+
MEMCACHED_CONNECTION_UDP,
|
112
|
+
MEMCACHED_CONNECTION_UNIX_SOCKET,
|
113
|
+
} memcached_connection;
|
114
|
+
|
115
|
+
typedef enum {
|
116
|
+
MEMCACHED_NOT_ALLOCATED,
|
117
|
+
MEMCACHED_ALLOCATED,
|
118
|
+
MEMCACHED_USED,
|
119
|
+
} memcached_allocated;
|
120
|
+
|
121
|
+
struct memcached_server_st {
|
122
|
+
char hostname[MEMCACHED_MAX_HOST_LENGTH];
|
123
|
+
unsigned int port;
|
124
|
+
int fd;
|
125
|
+
unsigned int cursor_active;
|
126
|
+
char write_buffer[MEMCACHED_MAX_BUFFER];
|
127
|
+
size_t write_buffer_offset;
|
128
|
+
char *write_ptr;
|
129
|
+
char read_buffer[MEMCACHED_MAX_BUFFER];
|
130
|
+
size_t read_data_length;
|
131
|
+
size_t read_buffer_length;
|
132
|
+
char *read_ptr;
|
133
|
+
memcached_allocated sockaddr_inited;
|
134
|
+
struct addrinfo *address_info;
|
135
|
+
memcached_connection type;
|
136
|
+
uint8_t major_version;
|
137
|
+
uint8_t minor_version;
|
138
|
+
uint8_t micro_version;
|
139
|
+
uint16_t count;
|
140
|
+
};
|
141
|
+
|
142
|
+
struct memcached_stat_st {
|
143
|
+
uint32_t pid;
|
144
|
+
uint32_t uptime;
|
145
|
+
uint32_t threads;
|
146
|
+
uint32_t time;
|
147
|
+
uint32_t pointer_size;
|
148
|
+
uint32_t rusage_user_seconds;
|
149
|
+
uint32_t rusage_user_microseconds;
|
150
|
+
uint32_t rusage_system_seconds;
|
151
|
+
uint32_t rusage_system_microseconds;
|
152
|
+
uint32_t curr_items;
|
153
|
+
uint32_t total_items;
|
154
|
+
uint32_t limit_maxbytes;
|
155
|
+
uint32_t curr_connections;
|
156
|
+
uint32_t total_connections;
|
157
|
+
uint32_t connection_structures;
|
158
|
+
uint64_t bytes;
|
159
|
+
uint64_t cmd_get;
|
160
|
+
uint64_t cmd_set;
|
161
|
+
uint64_t get_hits;
|
162
|
+
uint64_t get_misses;
|
163
|
+
uint64_t evictions;
|
164
|
+
uint64_t bytes_read;
|
165
|
+
uint64_t bytes_written;
|
166
|
+
char version[MEMCACHED_VERSION_STRING];
|
167
|
+
};
|
168
|
+
|
169
|
+
struct memcached_string_st {
|
170
|
+
memcached_st *root;
|
171
|
+
memcached_allocated is_allocated;
|
172
|
+
char *string;
|
173
|
+
char *end;
|
174
|
+
size_t current_size;
|
175
|
+
size_t block_size;
|
176
|
+
};
|
177
|
+
|
178
|
+
struct memcached_result_st {
|
179
|
+
memcached_allocated is_allocated;
|
180
|
+
memcached_st *root;
|
181
|
+
char key[MEMCACHED_MAX_KEY];
|
182
|
+
size_t key_length;
|
183
|
+
memcached_string_st value;
|
184
|
+
uint32_t flags;
|
185
|
+
uint64_t cas;
|
186
|
+
/* Add result callback function */
|
187
|
+
};
|
188
|
+
|
189
|
+
struct memcached_st {
|
190
|
+
memcached_allocated is_allocated;
|
191
|
+
memcached_server_st *hosts;
|
192
|
+
unsigned int number_of_hosts;
|
193
|
+
unsigned int cursor_server;
|
194
|
+
char connected;
|
195
|
+
int cached_errno;
|
196
|
+
unsigned long long flags;
|
197
|
+
int send_size;
|
198
|
+
int recv_size;
|
199
|
+
int32_t poll_timeout;
|
200
|
+
memcached_result_st result;
|
201
|
+
memcached_hash hash;
|
202
|
+
memcached_server_distribution distribution;
|
203
|
+
void *user_data;
|
204
|
+
unsigned int wheel[MEMCACHED_WHEEL_SIZE];
|
205
|
+
#ifdef NOT_USED /* Future Use */
|
206
|
+
uint8_t replicas;
|
207
|
+
memcached_return warning;
|
208
|
+
#endif
|
209
|
+
};
|
210
|
+
|
211
|
+
/* Public API */
|
212
|
+
memcached_st *memcached_create(memcached_st *ptr);
|
213
|
+
void memcached_free(memcached_st *ptr);
|
214
|
+
memcached_st *memcached_clone(memcached_st *clone, memcached_st *ptr);
|
215
|
+
|
216
|
+
memcached_return memcached_delete(memcached_st *ptr, char *key, size_t key_length,
|
217
|
+
time_t expiration);
|
218
|
+
memcached_return memcached_increment(memcached_st *ptr,
|
219
|
+
char *key, size_t key_length,
|
220
|
+
uint32_t offset,
|
221
|
+
uint64_t *value);
|
222
|
+
memcached_return memcached_decrement(memcached_st *ptr,
|
223
|
+
char *key, size_t key_length,
|
224
|
+
uint32_t offset,
|
225
|
+
uint64_t *value);
|
226
|
+
void memcached_stat_free(memcached_st *, memcached_stat_st *);
|
227
|
+
memcached_stat_st *memcached_stat(memcached_st *ptr, char *args, memcached_return *error);
|
228
|
+
memcached_return memcached_stat_servername(memcached_stat_st *stat, char *args,
|
229
|
+
char *hostname, unsigned int port);
|
230
|
+
memcached_return memcached_flush(memcached_st *ptr, time_t expiration);
|
231
|
+
memcached_return memcached_verbosity(memcached_st *ptr, unsigned int verbosity);
|
232
|
+
void memcached_quit(memcached_st *ptr);
|
233
|
+
char *memcached_strerror(memcached_st *ptr, memcached_return rc);
|
234
|
+
memcached_return memcached_behavior_set(memcached_st *ptr, memcached_behavior flag, void *data);
|
235
|
+
unsigned long long memcached_behavior_get(memcached_st *ptr, memcached_behavior flag);
|
236
|
+
|
237
|
+
/* All of the functions for adding data to the server */
|
238
|
+
memcached_return memcached_set(memcached_st *ptr, char *key, size_t key_length,
|
239
|
+
char *value, size_t value_length,
|
240
|
+
time_t expiration,
|
241
|
+
uint32_t flags);
|
242
|
+
memcached_return memcached_add(memcached_st *ptr, char *key, size_t key_length,
|
243
|
+
char *value, size_t value_length,
|
244
|
+
time_t expiration,
|
245
|
+
uint32_t flags);
|
246
|
+
memcached_return memcached_replace(memcached_st *ptr, char *key, size_t key_length,
|
247
|
+
char *value, size_t value_length,
|
248
|
+
time_t expiration,
|
249
|
+
uint32_t flags);
|
250
|
+
memcached_return memcached_append(memcached_st *ptr,
|
251
|
+
char *key, size_t key_length,
|
252
|
+
char *value, size_t value_length,
|
253
|
+
time_t expiration,
|
254
|
+
uint32_t flags);
|
255
|
+
memcached_return memcached_prepend(memcached_st *ptr,
|
256
|
+
char *key, size_t key_length,
|
257
|
+
char *value, size_t value_length,
|
258
|
+
time_t expiration,
|
259
|
+
uint32_t flags);
|
260
|
+
memcached_return memcached_cas(memcached_st *ptr,
|
261
|
+
char *key, size_t key_length,
|
262
|
+
char *value, size_t value_length,
|
263
|
+
time_t expiration,
|
264
|
+
uint32_t flags,
|
265
|
+
uint64_t cas);
|
266
|
+
|
267
|
+
/* Get functions */
|
268
|
+
char *memcached_get(memcached_st *ptr, char *key, size_t key_length,
|
269
|
+
size_t *value_length,
|
270
|
+
uint32_t *flags,
|
271
|
+
memcached_return *error);
|
272
|
+
memcached_return memcached_mget(memcached_st *ptr,
|
273
|
+
char **keys, size_t *key_length,
|
274
|
+
unsigned int number_of_keys);
|
275
|
+
char *memcached_fetch(memcached_st *ptr, char *key, size_t *key_length,
|
276
|
+
size_t *value_length, uint32_t *flags,
|
277
|
+
memcached_return *error);
|
278
|
+
memcached_result_st *memcached_fetch_result(memcached_st *ptr,
|
279
|
+
memcached_result_st *result,
|
280
|
+
memcached_return *error);
|
281
|
+
|
282
|
+
/* Server Public functions */
|
283
|
+
#define memcached_server_count(A) (A)->number_of_hosts
|
284
|
+
#define memcached_server_name(A,B) (B).hostname
|
285
|
+
#define memcached_server_port(A,B) (B).port
|
286
|
+
#define memcached_server_list(A) (A)->hosts
|
287
|
+
#define memcached_server_response_count(A,B) (A)->hosts[B].cursor_active
|
288
|
+
|
289
|
+
memcached_return memcached_server_add_udp(memcached_st *ptr,
|
290
|
+
char *hostname,
|
291
|
+
unsigned int port);
|
292
|
+
memcached_return memcached_server_add_unix_socket(memcached_st *ptr,
|
293
|
+
char *filename);
|
294
|
+
memcached_return memcached_server_add(memcached_st *ptr, char *hostname,
|
295
|
+
unsigned int port);
|
296
|
+
void memcached_server_list_free(memcached_server_st *ptr);
|
297
|
+
memcached_return memcached_server_push(memcached_st *ptr, memcached_server_st *list);
|
298
|
+
|
299
|
+
memcached_server_st *memcached_server_list_append(memcached_server_st *ptr,
|
300
|
+
char *hostname, unsigned int port,
|
301
|
+
memcached_return *error);
|
302
|
+
unsigned int memcached_server_list_count(memcached_server_st *ptr);
|
303
|
+
memcached_server_st *memcached_servers_parse(char *server_strings);
|
304
|
+
|
305
|
+
char *memcached_stat_get_value(memcached_st *ptr, memcached_stat_st *stat,
|
306
|
+
char *key, memcached_return *error);
|
307
|
+
char ** memcached_stat_get_keys(memcached_st *ptr, memcached_stat_st *stat,
|
308
|
+
memcached_return *error);
|
309
|
+
|
310
|
+
char *memcached_get_by_key(memcached_st *ptr,
|
311
|
+
char *master_key, size_t master_key_length,
|
312
|
+
char *key, size_t key_length,
|
313
|
+
size_t *value_length,
|
314
|
+
uint32_t *flags,
|
315
|
+
memcached_return *error);
|
316
|
+
|
317
|
+
memcached_return memcached_mget_by_key(memcached_st *ptr,
|
318
|
+
char *master_key, size_t master_key_length,
|
319
|
+
char **keys, size_t *key_length,
|
320
|
+
unsigned int number_of_keys);
|
321
|
+
|
322
|
+
memcached_return memcached_set_by_key(memcached_st *ptr,
|
323
|
+
char *master_key, size_t master_key_length,
|
324
|
+
char *key, size_t key_length,
|
325
|
+
char *value, size_t value_length,
|
326
|
+
time_t expiration,
|
327
|
+
uint32_t flags);
|
328
|
+
|
329
|
+
memcached_return memcached_add_by_key(memcached_st *ptr,
|
330
|
+
char *master_key, size_t master_key_length,
|
331
|
+
char *key, size_t key_length,
|
332
|
+
char *value, size_t value_length,
|
333
|
+
time_t expiration,
|
334
|
+
uint32_t flags);
|
335
|
+
|
336
|
+
memcached_return memcached_replace_by_key(memcached_st *ptr,
|
337
|
+
char *master_key, size_t master_key_length,
|
338
|
+
char *key, size_t key_length,
|
339
|
+
char *value, size_t value_length,
|
340
|
+
time_t expiration,
|
341
|
+
uint32_t flags);
|
342
|
+
|
343
|
+
memcached_return memcached_prepend_by_key(memcached_st *ptr,
|
344
|
+
char *master_key, size_t master_key_length,
|
345
|
+
char *key, size_t key_length,
|
346
|
+
char *value, size_t value_length,
|
347
|
+
time_t expiration,
|
348
|
+
uint32_t flags);
|
349
|
+
|
350
|
+
memcached_return memcached_append_by_key(memcached_st *ptr,
|
351
|
+
char *master_key, size_t master_key_length,
|
352
|
+
char *key, size_t key_length,
|
353
|
+
char *value, size_t value_length,
|
354
|
+
time_t expiration,
|
355
|
+
uint32_t flags);
|
356
|
+
|
357
|
+
memcached_return memcached_cas_by_key(memcached_st *ptr,
|
358
|
+
char *master_key, size_t master_key_length,
|
359
|
+
char *key, size_t key_length,
|
360
|
+
char *value, size_t value_length,
|
361
|
+
time_t expiration,
|
362
|
+
uint32_t flags,
|
363
|
+
uint64_t cas);
|
364
|
+
memcached_return memcached_delete_by_key(memcached_st *ptr,
|
365
|
+
char *master_key, size_t master_key_length,
|
366
|
+
char *key, size_t key_length,
|
367
|
+
time_t expiration);
|
368
|
+
|
369
|
+
memcached_return memcached_fetch_execute(memcached_st *ptr,
|
370
|
+
unsigned int (*callback[])(memcached_st *ptr, memcached_result_st *result, void *context),
|
371
|
+
void *context,
|
372
|
+
unsigned int number_of_callbacks
|
373
|
+
);
|
374
|
+
|
375
|
+
/* Result Struct */
|
376
|
+
void memcached_result_free(memcached_result_st *result);
|
377
|
+
memcached_result_st *memcached_result_create(memcached_st *ptr,
|
378
|
+
memcached_result_st *result);
|
379
|
+
#define memcached_result_key_value(A) (A)->key
|
380
|
+
#define memcached_result_key_length(A) (A)->key_length
|
381
|
+
#ifdef FIX
|
382
|
+
#define memcached_result_value(A) memcached_string_value((A)->value)
|
383
|
+
#define memcached_result_length(A) memcached_string_length((A)->value)
|
384
|
+
#else
|
385
|
+
char *memcached_result_value(memcached_result_st *ptr);
|
386
|
+
size_t memcached_result_length(memcached_result_st *ptr);
|
387
|
+
#endif
|
388
|
+
#define memcached_result_flags(A) (A)->flags
|
389
|
+
#define memcached_result_cas(A) (A)->cas
|
390
|
+
|
391
|
+
|
392
|
+
#ifndef __WATCHPOINT_H__
|
393
|
+
#define __WATCHPOINT_H__
|
394
|
+
/* Some personal debugging functions */
|
395
|
+
#ifdef HAVE_DEBUG
|
396
|
+
#define WATCHPOINT fprintf(stderr, "\nWATCHPOINT %s:%d (%s)\n", __FILE__, __LINE__,__func__);fflush(stdout);
|
397
|
+
#ifdef __MEMCACHED_H__
|
398
|
+
#define WATCHPOINT_ERROR(A) fprintf(stderr, "\nWATCHPOINT %s:%d %s\n", __FILE__, __LINE__, memcached_strerror(NULL, A));fflush(stdout);
|
399
|
+
#define WATCHPOINT_IFERROR(A) if(A != MEMCACHED_SUCCESS)fprintf(stderr, "\nWATCHPOINT %s:%d %s\n", __FILE__, __LINE__, memcached_strerror(NULL, A));fflush(stdout);
|
400
|
+
#endif
|
401
|
+
#define WATCHPOINT_STRING(A) fprintf(stderr, "\nWATCHPOINT %s:%d (%s) %s\n", __FILE__, __LINE__,__func__,A);fflush(stdout);
|
402
|
+
#define WATCHPOINT_STRING_LENGTH(A,B) fprintf(stderr, "\nWATCHPOINT %s:%d (%s) %.*s\n", __FILE__, __LINE__,__func__,(int)B,A);fflush(stdout);
|
403
|
+
#define WATCHPOINT_NUMBER(A) fprintf(stderr, "\nWATCHPOINT %s:%d (%s) %zu\n", __FILE__, __LINE__,__func__,(size_t)(A));fflush(stdout);
|
404
|
+
#define WATCHPOINT_ERRNO(A) fprintf(stderr, "\nWATCHPOINT %s:%d (%s) %s\n", __FILE__, __LINE__,__func__, strerror(A));A= 0;fflush(stdout);
|
405
|
+
#define WATCHPOINT_ASSERT(A) assert((A));
|
406
|
+
#else
|
407
|
+
#define WATCHPOINT
|
408
|
+
#ifdef __MEMCACHED_H__
|
409
|
+
#define WATCHPOINT_ERROR(A)
|
410
|
+
#define WATCHPOINT_IFERROR(A)
|
411
|
+
#endif
|
412
|
+
#define WATCHPOINT_STRING(A)
|
413
|
+
#define WATCHPOINT_NUMBER(A)
|
414
|
+
#define WATCHPOINT_ERRNO(A)
|
415
|
+
#define WATCHPOINT_ASSERT(A)
|
416
|
+
#endif
|
417
|
+
|
418
|
+
#endif /* __WATCHPOINT_H__ */
|
419
|
+
|
420
|
+
|
421
|
+
#ifdef __cplusplus
|
422
|
+
}
|
423
|
+
#endif
|
424
|
+
|
425
|
+
#endif /* __MEMCACHED_H__ */
|