dalli 3.0.1 → 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 +42 -12
- data/README.md +25 -139
- data/lib/dalli/cas/client.rb +2 -0
- data/lib/dalli/client.rb +188 -188
- 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 +274 -483
- data/lib/dalli/protocol/server_config_parser.rb +84 -0
- data/lib/dalli/protocol/ttl_sanitizer.rb +45 -0
- data/lib/dalli/protocol/value_compressor.rb +85 -0
- 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 +98 -45
- data/lib/dalli/version.rb +3 -1
- data/lib/dalli.rb +31 -11
- data/lib/rack/session/dalli.rb +28 -18
- metadata +60 -7
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,36 @@
|
|
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
|
+
|
11
|
+
3.0.4
|
12
|
+
==========
|
13
|
+
|
14
|
+
- Clean connections and retry after NetworkError in get_multi (andrejbl)
|
15
|
+
- Internal refactoring and cleanup (petergoldstein)
|
16
|
+
|
17
|
+
3.0.3
|
18
|
+
==========
|
19
|
+
|
20
|
+
- Restore ability for `compress` to be disabled on a per request basis (petergoldstein)
|
21
|
+
- Fix broken image in README (deining)
|
22
|
+
- Use bundler-cache in CI (olleolleolle)
|
23
|
+
- Remove the OpenSSL extensions dependency (petergoldstein)
|
24
|
+
- Add Memcached 1.5.x to the CI matrix
|
25
|
+
- Updated compression documentation (petergoldstein)
|
26
|
+
|
27
|
+
3.0.2
|
28
|
+
==========
|
29
|
+
|
30
|
+
- Restore Windows compatibility (petergoldstein)
|
31
|
+
- Add JRuby to CI and make requisite changes (petergoldstein)
|
32
|
+
- Clarify documentation for supported rubies (petergoldstein)
|
33
|
+
|
4
34
|
3.0.1
|
5
35
|
==========
|
6
36
|
|
@@ -11,18 +41,18 @@ Dalli Changelog
|
|
11
41
|
==========
|
12
42
|
- BREAKING CHANGES:
|
13
43
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
44
|
+
* Removes :dalli_store.
|
45
|
+
Use Rails' official :mem_cache_store instead.
|
46
|
+
https://guides.rubyonrails.org/caching_with_rails.html
|
47
|
+
* Attempting to store a larger value than allowed by memcached used to
|
48
|
+
print a warning and truncate the value. This now raises an error to
|
49
|
+
prevent silent data corruption.
|
50
|
+
* Compression now defaults to `true` for large values (greater than 4KB).
|
51
|
+
This is intended to minimize errors due to the previous note.
|
52
|
+
* Errors marshalling values now raise rather than just printing an error.
|
53
|
+
* The Rack session adapter has been refactored to remove support for thread-unsafe
|
54
|
+
configurations. You will need to include the `connection_pool` gem in
|
55
|
+
your Gemfile to ensure session operations are thread-safe.
|
26
56
|
|
27
57
|
- Raise NetworkError when multi response gets into corrupt state (mervync, #783)
|
28
58
|
- Validate servers argument (semaperepelitsa, petergoldstein, #776)
|
data/README.md
CHANGED
@@ -1,164 +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](http://www.virtualdali.com/assets/paintings/31PersistenceOfMemory.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
|
-
Dalli should work identically on:
|
16
|
-
|
17
|
-
* JRuby 1.6+
|
18
|
-
* Ruby 1.9.3+
|
19
|
-
* Rubinius 2.0
|
20
|
-
|
21
|
-
If you have problems, please enter an issue.
|
22
|
-
|
23
|
-
|
24
|
-
Installation and Usage
|
25
|
-
------------------------
|
26
|
-
|
27
|
-
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 memcached 1.4.x using Homebrew with
|
28
|
-
|
29
|
-
brew install memcached
|
30
|
-
|
31
|
-
On Ubuntu you can install it by running:
|
32
|
-
|
33
|
-
apt-get install memcached
|
34
|
-
|
35
|
-
You can verify your installation using this piece of code:
|
36
|
-
|
37
|
-
```bash
|
38
|
-
gem install dalli
|
39
|
-
```
|
40
|
-
|
41
|
-
```ruby
|
42
|
-
require 'dalli'
|
43
|
-
options = { :namespace => "app_v1", :compress => true }
|
44
|
-
dc = Dalli::Client.new('localhost:11211', options)
|
45
|
-
dc.set('abc', 123)
|
46
|
-
value = dc.get('abc')
|
47
|
-
```
|
48
|
-
|
49
|
-
With SSL enabled:
|
50
|
-
```ruby
|
51
|
-
require 'dalli'
|
52
|
-
ssl_context = OpenSSL::SSL::SSLContext.new
|
53
|
-
ssl_context.ca_file = "./myCA.pem"
|
54
|
-
ssl_context.ssl_version = :SSLv23
|
55
|
-
ssl_context.verify_hostname = true
|
56
|
-
ssl_context.verify_mode = OpenSSL::SSL::VERIFY_PEER
|
57
|
-
|
58
|
-
dc = Dalli::Client.new("memcached:11212", :ssl_context => ssl_context)
|
59
|
-
dc.set("abc", 123)
|
60
|
-
value = dc.get("abc")
|
61
|
-
```
|
62
|
-
|
63
|
-
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.
|
64
|
-
|
65
|
-
Dalli has no runtime dependencies.
|
66
|
-
|
67
|
-
Configuration
|
68
|
-
------------------------
|
69
|
-
|
70
|
-
**servers**: An Array of "host:port:weight" where weight allows you to distribute cache unevenly.
|
71
|
-
|
72
|
-
Dalli::Client accepts the following options. All times are in seconds.
|
73
|
-
|
74
|
-
**expires_in**: Global default for key TTL. Default is 0, which means no expiry.
|
6
|
+
Dalli supports:
|
75
7
|
|
76
|
-
|
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
|
77
14
|
|
78
|
-
|
79
|
-
|
80
|
-
**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.
|
81
|
-
|
82
|
-
**serializer**: The serializer to use for objects being stored (ex. JSON).
|
83
|
-
Default is Marshal.
|
84
|
-
|
85
|
-
**compress**: Boolean, if true Dalli will gzip-compress values larger than 1K. Default is false.
|
86
|
-
|
87
|
-
**compression_min_size**: Minimum value byte size for which to attempt compression. Default is 1K.
|
88
|
-
|
89
|
-
**compression_max_size**: Maximum value byte size for which to attempt compression. Default is unlimited.
|
90
|
-
|
91
|
-
**compressor**: The compressor to use for objects being stored.
|
92
|
-
Default is zlib, implemented under `Dalli::Compressor`.
|
93
|
-
If serving compressed data using nginx's HttpMemcachedModule, set `memcached_gzip_flag 2` and use `Dalli::GzipCompressor`
|
94
|
-
|
95
|
-
**keepalive**: Boolean. If true, Dalli will enable keep-alive for socket connections. Default is true.
|
96
|
-
|
97
|
-
**socket_timeout**: Timeout for all socket operations (connect, read, write). Default is 1.
|
98
|
-
|
99
|
-
**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.
|
100
|
-
|
101
|
-
**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.
|
102
|
-
|
103
|
-
**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.
|
104
|
-
|
105
|
-
**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.
|
106
|
-
|
107
|
-
**error_when_over_max_size**: Boolean. If true, Dalli will throw a Dalli::ValueOverMaxSize exception when trying to store data larger than **value_max_bytes**. Defaults to false, meaning only a warning is logged.
|
108
|
-
|
109
|
-
**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.
|
110
|
-
|
111
|
-
**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.
|
112
|
-
|
113
|
-
**sndbuf**: In bytes, set the socket SO_SNDBUF. Defaults to operating system default.
|
114
|
-
|
115
|
-
**rcvbuf**: In bytes, set the socket SO_RCVBUF. Defaults to operating system default.
|
116
|
-
|
117
|
-
**cache_nils**: Boolean. If true Dalli will not treat cached `nil` values as 'not found' for `#fetch` operations. Default is false.
|
118
|
-
|
119
|
-
**raise_errors**: Boolean. When true DalliStore will reraise Dalli:DalliError instead swallowing the error. Default is false.
|
120
|
-
|
121
|
-
**instrument_errors**: Boolean. When true DalliStore will send notification of Dalli::DalliError via a 'cache_error.active_support' event. Default is false.
|
122
|
-
|
123
|
-
Features and Changes
|
124
|
-
------------------------
|
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).
|
125
16
|
|
126
|
-
|
17
|
+
![Persistence of Memory](https://upload.wikimedia.org/wikipedia/en/d/dd/The_Persistence_of_Memory.jpg)
|
127
18
|
|
128
|
-
Dalli does not need anything special in Unicorn/Passenger since 2.0.4.
|
129
|
-
It will detect sockets shared with child processes and gracefully reopen the
|
130
|
-
socket.
|
131
19
|
|
132
|
-
|
20
|
+
## Documentation and Information
|
133
21
|
|
134
|
-
[
|
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
|
135
27
|
|
136
|
-
|
137
|
-
-------------
|
28
|
+
## Contributing
|
138
29
|
|
139
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.
|
140
31
|
|
141
|
-
|
142
|
-
|
143
|
-
Thanks
|
144
|
-
------------
|
145
|
-
|
146
|
-
Mike Perham - for originally authoring the Dalli project and serving as maintainer and primary contributor
|
32
|
+
## Appreciation
|
147
33
|
|
148
|
-
|
34
|
+
Dalli would not exist in its current form without the contributions of many people. But special thanks go to several individuals and organizations:
|
149
35
|
|
150
|
-
|
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
|
151
40
|
|
152
|
-
[CouchBase](http://couchbase.com) - for their project sponsorship
|
153
41
|
|
154
|
-
Authors
|
155
|
-
----------
|
42
|
+
## Authors
|
156
43
|
|
157
44
|
* [Peter M. Goldstein](https://github.com/petergoldstein) - current maintainer
|
158
45
|
* [Mike Perham](https://github.com/mperham) and contributors
|
159
46
|
|
160
47
|
|
161
|
-
Copyright
|
162
|
-
-----------
|
48
|
+
## Copyright
|
163
49
|
|
164
50
|
Copyright (c) Mike Perham, Peter M. Goldstein. See LICENSE for details.
|
data/lib/dalli/cas/client.rb
CHANGED