dalli 3.0.4 → 3.0.5
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of dalli might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/Gemfile +11 -5
- data/History.md +7 -0
- data/README.md +25 -134
- data/lib/dalli/cas/client.rb +2 -0
- data/lib/dalli/client.rb +183 -193
- data/lib/dalli/compressor.rb +13 -4
- data/lib/dalli/key_manager.rb +113 -0
- data/lib/dalli/options.rb +2 -2
- data/lib/dalli/protocol/binary/request_formatter.rb +109 -0
- data/lib/dalli/protocol/binary/response_processor.rb +149 -0
- data/lib/dalli/protocol/binary/sasl_authentication.rb +57 -0
- data/lib/dalli/protocol/binary.rb +271 -430
- data/lib/dalli/protocol/server_config_parser.rb +23 -6
- data/lib/dalli/protocol/value_marshaller.rb +59 -0
- data/lib/dalli/protocol/value_serializer.rb +91 -0
- data/lib/dalli/protocol.rb +2 -3
- data/lib/dalli/ring.rb +91 -35
- data/lib/dalli/server.rb +2 -2
- data/lib/dalli/servers_arg_normalizer.rb +54 -0
- data/lib/dalli/socket.rb +96 -52
- data/lib/dalli/version.rb +3 -1
- data/lib/dalli.rb +31 -14
- data/lib/rack/session/dalli.rb +28 -18
- metadata +70 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b1d0533f940077d18e6689253325c1dd04ddcfe56963265c661b42d8bf8699f7
|
4
|
+
data.tar.gz: a50064a0845c9ed86acf2a68b3a7c37fff35ab687724fa263333dda098a9430a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c35e6c854ac914779a1cd874fb262047b3e1b442e383c234120487160d19c43aad1539106ee1f3e1503ee29fc9135460416f237c5ab9affe99a950bc0b612166
|
7
|
+
data.tar.gz: 348afdb59b0fe32ba729785c9fc5435abd6d89a3cdef49d124c4f10ac85f066e90180afdd2e91f4b140e0a175e42ff688e9081b73e2b2f6a3925ca8c27f190c6
|
data/Gemfile
CHANGED
@@ -1,10 +1,16 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
source 'https://rubygems.org'
|
2
4
|
|
3
5
|
gemspec
|
4
6
|
|
5
7
|
group :test do
|
6
|
-
gem
|
7
|
-
gem
|
8
|
-
gem
|
9
|
-
gem
|
8
|
+
gem 'minitest'
|
9
|
+
gem 'rake'
|
10
|
+
gem 'rubocop'
|
11
|
+
gem 'rubocop-minitest'
|
12
|
+
gem 'rubocop-performance'
|
13
|
+
gem 'rubocop-rake'
|
14
|
+
gem 'ruby-prof', platform: :mri
|
15
|
+
gem 'simplecov'
|
10
16
|
end
|
data/History.md
CHANGED
@@ -1,6 +1,13 @@
|
|
1
1
|
Dalli Changelog
|
2
2
|
=====================
|
3
3
|
|
4
|
+
3.0.5
|
5
|
+
==========
|
6
|
+
|
7
|
+
- Add Rubocop and fix most outstanding issues (petergoldstein)
|
8
|
+
- Extract a number of classes, to simplify the largest classes (petergoldstein)
|
9
|
+
- Ensure against socket corruption if an error occurs in a multi block (petergoldstein)
|
10
|
+
|
4
11
|
3.0.4
|
5
12
|
==========
|
6
13
|
|
data/README.md
CHANGED
@@ -1,159 +1,50 @@
|
|
1
1
|
Dalli [![Tests](https://github.com/petergoldstein/dalli/actions/workflows/tests.yml/badge.svg)](https://github.com/petergoldstein/dalli/actions/workflows/tests.yml)
|
2
2
|
=====
|
3
3
|
|
4
|
-
Dalli is a high performance pure Ruby client for accessing memcached servers.
|
4
|
+
Dalli is a high performance pure Ruby client for accessing memcached servers.
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
![Persistence of Memory](https://upload.wikimedia.org/wikipedia/en/d/dd/The_Persistence_of_Memory.jpg)
|
9
|
-
|
10
|
-
Dalli's initial development was sponsored by [CouchBase](http://www.couchbase.com/). Many thanks to them!
|
11
|
-
|
12
|
-
Supported Ruby versions and implementations
|
13
|
-
------------------------------------------------
|
14
|
-
|
15
|
-
As of Dalli version 3.0 the following Ruby versions are supported:
|
16
|
-
|
17
|
-
* Ruby 2.5.x, 2.6.x, 2.7.x, 3.0.x
|
18
|
-
* JRuby 9.2.x, 9.3.x
|
19
|
-
|
20
|
-
If you have problems, please enter an issue.
|
21
|
-
|
22
|
-
|
23
|
-
Installation and Usage
|
24
|
-
------------------------
|
25
|
-
|
26
|
-
Remember, Dalli **requires** memcached 1.4+. You can check the version with `memcached -h`. Please note that the memcached version that *Mac OS X Snow Leopard* ships with is 1.2.8 and it won't work. Install the most recent version of memcached using Homebrew with
|
27
|
-
|
28
|
-
brew install memcached
|
29
|
-
|
30
|
-
On Ubuntu you can install it by running:
|
31
|
-
|
32
|
-
apt-get install memcached
|
33
|
-
|
34
|
-
You can verify your installation using this piece of code:
|
35
|
-
|
36
|
-
```bash
|
37
|
-
gem install dalli
|
38
|
-
```
|
39
|
-
|
40
|
-
```ruby
|
41
|
-
require 'dalli'
|
42
|
-
options = { namespace: "app_v1", compress: true }
|
43
|
-
dc = Dalli::Client.new('localhost:11211', options)
|
44
|
-
dc.set('abc', 123)
|
45
|
-
value = dc.get('abc')
|
46
|
-
```
|
47
|
-
|
48
|
-
With SSL enabled:
|
49
|
-
```ruby
|
50
|
-
require 'dalli'
|
51
|
-
ssl_context = OpenSSL::SSL::SSLContext.new
|
52
|
-
ssl_context.ca_file = "./myCA.pem"
|
53
|
-
ssl_context.ssl_version = :SSLv23
|
54
|
-
ssl_context.verify_hostname = true if ssl_context.respond_to?(:verify_hostname=)
|
55
|
-
ssl_context.verify_mode = OpenSSL::SSL::VERIFY_PEER
|
56
|
-
|
57
|
-
dc = Dalli::Client.new("memcached:11212", ssl_context: ssl_context)
|
58
|
-
dc.set("abc", 123)
|
59
|
-
value = dc.get("abc")
|
60
|
-
```
|
61
|
-
|
62
|
-
The test suite requires memcached 1.4.3+ with SASL enabled (`brew install memcached --enable-sasl ; mv /usr/bin/memcached /usr/bin/memcached.old`). Currently only supports the PLAIN mechanism.
|
63
|
-
|
64
|
-
Dalli has no runtime dependencies.
|
65
|
-
|
66
|
-
Configuration
|
67
|
-
------------------------
|
68
|
-
|
69
|
-
**servers**: An Array of "host:port:weight" where weight allows you to distribute cache unevenly.
|
70
|
-
|
71
|
-
Dalli::Client accepts the following options. All times are in seconds.
|
6
|
+
Dalli supports:
|
72
7
|
|
73
|
-
|
8
|
+
* Simple and complex memcached configurations
|
9
|
+
* Failover between memcached instances
|
10
|
+
* Fine-grained control of data serialization and compression
|
11
|
+
* Thread-safe operation (either through use of a connection pool, or by using the Dalli client in threadsafe mode)
|
12
|
+
* SSL/TLS connections to memcached
|
13
|
+
* SASL authentication
|
74
14
|
|
75
|
-
|
76
|
-
|
77
|
-
**failover**: Boolean, if true Dalli will failover to another server if the main server for a key is down. Default is true.
|
78
|
-
|
79
|
-
**threadsafe**: Boolean. If true Dalli ensures that only one thread is using a socket at a given time. Default is true. You can set to false if you are using the Client within a thread-safe connection pool.
|
80
|
-
|
81
|
-
**serializer**: The serializer to use for objects being stored (ex. JSON).
|
82
|
-
Default is Marshal.
|
83
|
-
|
84
|
-
**compress**: Boolean, if true Dalli will gzip-compress values larger than compression_min_size. Can be overridden on a per-request basis. Default is true.
|
85
|
-
|
86
|
-
**compression_min_size**: Minimum value byte size for which to attempt compression. Default is 4K.
|
87
|
-
|
88
|
-
**compressor**: The compressor to use for objects being stored.
|
89
|
-
Default is zlib, implemented under `Dalli::Compressor`.
|
90
|
-
If serving compressed data using nginx's HttpMemcachedModule, set `memcached_gzip_flag 2` and use `Dalli::GzipCompressor`
|
91
|
-
|
92
|
-
**keepalive**: Boolean. If true, Dalli will enable keep-alive for socket connections. Default is true.
|
93
|
-
|
94
|
-
**socket_timeout**: Timeout for all socket operations (connect, read, write). Default is 1.
|
95
|
-
|
96
|
-
**socket_max_failures**: When a socket operation fails after socket_timeout, the same operation is retried. This is to not immediately mark a server down when there's a very slight network problem. Default is 2.
|
97
|
-
|
98
|
-
**socket_failure_delay**: Before retrying a socket operation, the process sleeps for this amount of time. Default is 0.1. Set to nil for no delay.
|
99
|
-
|
100
|
-
**down_retry_delay**: When a server has been marked down due to many failures, the server will be checked again for being alive only after this amount of time. Don't set this value too low, otherwise each request which tries the failed server might hang for the maximum **socket_timeout**. Default is 30 seconds.
|
101
|
-
|
102
|
-
**value_max_bytes**: The maximum size of a value in memcached. Defaults to 1MB, this can be increased with memcached's -I parameter. You must also configure Dalli to allow the larger size here.
|
103
|
-
|
104
|
-
**username**: The username to use for authenticating this client instance against a SASL-enabled memcached server. Heroku users should not need to use this normally.
|
105
|
-
|
106
|
-
**password**: The password to use for authenticating this client instance against a SASL-enabled memcached server. Heroku users should not need to use this normally.
|
107
|
-
|
108
|
-
**sndbuf**: In bytes, set the socket SO_SNDBUF. Defaults to operating system default.
|
109
|
-
|
110
|
-
**rcvbuf**: In bytes, set the socket SO_RCVBUF. Defaults to operating system default.
|
111
|
-
|
112
|
-
**cache_nils**: Boolean. If true Dalli will not treat cached `nil` values as 'not found' for `#fetch` operations. Default is false.
|
113
|
-
|
114
|
-
**raise_errors**: Boolean. When true DalliStore will reraise Dalli:DalliError instead swallowing the error. Default is false.
|
115
|
-
|
116
|
-
**instrument_errors**: Boolean. When true DalliStore will send notification of Dalli::DalliError via a 'cache_error.active_support' event. Default is false.
|
117
|
-
|
118
|
-
Features and Changes
|
119
|
-
------------------------
|
15
|
+
The name is a variant of Salvador Dali for his famous painting [The Persistence of Memory](http://en.wikipedia.org/wiki/The_Persistence_of_Memory).
|
120
16
|
|
121
|
-
|
17
|
+
![Persistence of Memory](https://upload.wikimedia.org/wikipedia/en/d/dd/The_Persistence_of_Memory.jpg)
|
122
18
|
|
123
|
-
Dalli does not need anything special in Unicorn/Passenger since 2.0.4.
|
124
|
-
It will detect sockets shared with child processes and gracefully reopen the
|
125
|
-
socket.
|
126
19
|
|
127
|
-
|
20
|
+
## Documentation and Information
|
128
21
|
|
129
|
-
[
|
22
|
+
* [User Documentation](https://github.com/petergoldstein/dalli/wiki) - The documentation is maintained in the repository's wiki.
|
23
|
+
* [Announcements](https://github.com/petergoldstein/dalli/discussions/categories/announcements) - Announcements of interest to the Dalli community will be posted here.
|
24
|
+
* [Bug Reports](https://github.com/petergoldstein/dalli/issues) - If you discover a problem with Dalli, please submit a bug report in the tracker.
|
25
|
+
* [Forum](https://github.com/petergoldstein/dalli/discussions/categories/q-a) - If you have questions about Dalli, please post them here.
|
26
|
+
* [Client API](https://www.rubydoc.info/github/petergoldstein/dalli/master/Dalli/Client) - Ruby documentation for the `Dalli::Client` API
|
130
27
|
|
131
|
-
|
132
|
-
-------------
|
28
|
+
## Contributing
|
133
29
|
|
134
30
|
If you have a fix you wish to provide, please fork the code, fix in your local project and then send a pull request on github. Please ensure that you include a test which verifies your fix and update `History.md` with a one sentence description of your fix so you get credit as a contributor.
|
135
31
|
|
136
|
-
|
137
|
-
|
138
|
-
Thanks
|
139
|
-
------------
|
140
|
-
|
141
|
-
Mike Perham - for originally authoring the Dalli project and serving as maintainer and primary contributor
|
32
|
+
## Appreciation
|
142
33
|
|
143
|
-
|
34
|
+
Dalli would not exist in its current form without the contributions of many people. But special thanks go to several individuals and organizations:
|
144
35
|
|
145
|
-
|
36
|
+
* Mike Perham - for originally authoring the Dalli project and serving as maintainer and primary contributor for many years
|
37
|
+
* Eric Wong - for help using his [kgio](http://bogomips.org/kgio/) library.
|
38
|
+
* Brian Mitchell - for his remix-stash project which was helpful when implementing and testing the binary protocol support.
|
39
|
+
* [CouchBase](http://couchbase.com) - for their sponsorship of the original development
|
146
40
|
|
147
|
-
[CouchBase](http://couchbase.com) - for their project sponsorship
|
148
41
|
|
149
|
-
Authors
|
150
|
-
----------
|
42
|
+
## Authors
|
151
43
|
|
152
44
|
* [Peter M. Goldstein](https://github.com/petergoldstein) - current maintainer
|
153
45
|
* [Mike Perham](https://github.com/mperham) and contributors
|
154
46
|
|
155
47
|
|
156
|
-
Copyright
|
157
|
-
-----------
|
48
|
+
## Copyright
|
158
49
|
|
159
50
|
Copyright (c) Mike Perham, Peter M. Goldstein. See LICENSE for details.
|
data/lib/dalli/cas/client.rb
CHANGED