dalli 2.7.6 → 3.2.8

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.
Files changed (40) hide show
  1. checksums.yaml +5 -5
  2. data/{History.md → CHANGELOG.md} +218 -0
  3. data/Gemfile +17 -1
  4. data/README.md +30 -210
  5. data/lib/dalli/cas/client.rb +2 -57
  6. data/lib/dalli/client.rb +228 -254
  7. data/lib/dalli/compressor.rb +13 -2
  8. data/lib/dalli/key_manager.rb +121 -0
  9. data/lib/dalli/options.rb +7 -7
  10. data/lib/dalli/pid_cache.rb +40 -0
  11. data/lib/dalli/pipelined_getter.rb +177 -0
  12. data/lib/dalli/protocol/base.rb +250 -0
  13. data/lib/dalli/protocol/binary/request_formatter.rb +117 -0
  14. data/lib/dalli/protocol/binary/response_header.rb +36 -0
  15. data/lib/dalli/protocol/binary/response_processor.rb +239 -0
  16. data/lib/dalli/protocol/binary/sasl_authentication.rb +60 -0
  17. data/lib/dalli/protocol/binary.rb +173 -0
  18. data/lib/dalli/protocol/connection_manager.rb +255 -0
  19. data/lib/dalli/protocol/meta/key_regularizer.rb +31 -0
  20. data/lib/dalli/protocol/meta/request_formatter.rb +121 -0
  21. data/lib/dalli/protocol/meta/response_processor.rb +211 -0
  22. data/lib/dalli/protocol/meta.rb +178 -0
  23. data/lib/dalli/protocol/response_buffer.rb +54 -0
  24. data/lib/dalli/protocol/server_config_parser.rb +86 -0
  25. data/lib/dalli/protocol/ttl_sanitizer.rb +45 -0
  26. data/lib/dalli/protocol/value_compressor.rb +85 -0
  27. data/lib/dalli/protocol/value_marshaller.rb +59 -0
  28. data/lib/dalli/protocol/value_serializer.rb +91 -0
  29. data/lib/dalli/protocol.rb +19 -0
  30. data/lib/dalli/ring.rb +95 -84
  31. data/lib/dalli/server.rb +4 -743
  32. data/lib/dalli/servers_arg_normalizer.rb +54 -0
  33. data/lib/dalli/socket.rb +142 -127
  34. data/lib/dalli/version.rb +5 -1
  35. data/lib/dalli.rb +46 -15
  36. data/lib/rack/session/dalli.rb +156 -50
  37. metadata +36 -128
  38. data/lib/action_dispatch/middleware/session/dalli_store.rb +0 -81
  39. data/lib/active_support/cache/dalli_store.rb +0 -403
  40. data/lib/dalli/railtie.rb +0 -7
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: aa780eecd8063c6371f755a081c672bee694c596
4
- data.tar.gz: f044315c06b99f3ff10da4c4a37a4b77cce359da
2
+ SHA256:
3
+ metadata.gz: c7d8b3dd9e76a224d876f901dc44c3cf8016326209df3efc7fe522053a4a3c22
4
+ data.tar.gz: 0ced058a6a170cadd4b74268de5417c4a1e700baf5767fc8f260db9477e2b735
5
5
  SHA512:
6
- metadata.gz: 962196b3d7c2a75b928f32e896106ead0316b6d2614f1176041a3751c82816e5669a70d9d293ef1762df190bade229955b20c5673562600575774b3bfed6c978
7
- data.tar.gz: c890f77ce55953a3f0fe47629ddb1eda40ece7b58628c7168e45c3733c5120e72c7dba992f6b15267ea5025283bf8f5c2e213648c65e6a87131219bfe318f5a1
6
+ metadata.gz: 3e316a4d60c3327cecec46a0a34c52536130199124035c375bf1933676d85fbf09e99a985ae44faf4e27b0fb1f8b8faef1656a812e6bdfc387406c5e18874461
7
+ data.tar.gz: bce3e0e41c280e99889bea6835c1b2f701cbcb5e4f398203ae2b4d6ebc05cdc505ee5955365715f8e00441d69701ceac84de37a98eac8581d003d1ab411a33e9
@@ -1,6 +1,224 @@
1
1
  Dalli Changelog
2
2
  =====================
3
3
 
4
+ Unreleased
5
+ ==========
6
+
7
+ 3.2.8
8
+ ==========
9
+
10
+ - Handle IO::TimeoutError when establishing connection (eugeneius)
11
+ - Drop dependency on base64 gem (Earlopain)
12
+ - Address incompatibility with resolv-replace (y9v)
13
+ - Add rubygems.org metadata (m-nakamura145)
14
+
15
+ 3.2.7
16
+ ==========
17
+
18
+ - Fix cascading error when there's an underlying network error in a pipelined get (eugeneius)
19
+ - Ruby 3.4/head compatibility by adding base64 to gemspec (tagliala)
20
+ - Add Ruby 3.3 to CI (m-nakamura145)
21
+ - Use Socket's connect_timeout when available, and pass timeout to the socket's send and receive timeouts (mlarraz)
22
+
23
+ 3.2.6
24
+ ==========
25
+
26
+ - Rescue IO::TimeoutError raised by Ruby since 3.2.0 on blocking reads/writes (skaes)
27
+ - Fix rubydoc link (JuanitoFatas)
28
+
29
+ 3.2.5
30
+ ==========
31
+
32
+ - Better handle memcached requests being interrupted by Thread#raise or Thread#kill (byroot)
33
+ - Unexpected errors are no longer treated as `Dalli::NetworkError`, including errors raised by `Timeout.timeout` (byroot)
34
+
35
+ 3.2.4
36
+ ==========
37
+
38
+ - Cache PID calls for performance since glibc no longer caches in recent versions (byroot)
39
+ - Preallocate the read buffer in Socket#readfull (byroot)
40
+
41
+ 3.2.3
42
+ ==========
43
+
44
+ - Sanitize CAS inputs to ensure additional commands are not passed to memcached (xhzeem / petergoldstein)
45
+ - Sanitize input to flush command to ensure additional commands are not passed to memcached (xhzeem / petergoldstein)
46
+ - Namespaces passed as procs are now evaluated every time, as opposed to just on initialization (nrw505)
47
+ - Fix missing require of uri in ServerConfigParser (adam12)
48
+ - Fix link to the CHANGELOG.md file in README.md (rud)
49
+
50
+ 3.2.2
51
+ ==========
52
+
53
+ - Ensure apps are resilient against old session ids (kbrock)
54
+
55
+ 3.2.1
56
+ ==========
57
+
58
+ - Fix null replacement bug on some SASL-authenticated services (veritas1)
59
+
60
+ 3.2.0
61
+ ==========
62
+
63
+ - BREAKING CHANGE: Remove protocol_implementation client option (petergoldstein)
64
+ - Add protocol option with meta implementation (petergoldstein)
65
+
66
+ 3.1.6
67
+ ==========
68
+
69
+ - Fix bug with cas/cas! with "Not found" value (petergoldstein)
70
+ - Add Ruby 3.1 to CI (petergoldstein)
71
+ - Replace reject(&:nil?) with compact (petergoldstein)
72
+
73
+ 3.1.5
74
+ ==========
75
+
76
+ - Fix bug with get_cas key with "Not found" value (petergoldstein)
77
+ - Replace should return nil, not raise error, on miss (petergoldstein)
78
+
79
+ 3.1.4
80
+ ==========
81
+
82
+ - Improve response parsing performance (byroot)
83
+ - Reorganize binary protocol parsing a bit (petergoldstein)
84
+ - Fix handling of non-ASCII keys in get_multi (petergoldstein)
85
+
86
+ 3.1.3
87
+ ==========
88
+
89
+ - Restore falsey behavior on delete/delete_cas for nonexistent key (petergoldstein)
90
+
91
+ 3.1.2
92
+ ==========
93
+
94
+ - Make quiet? / multi? public on Dalli::Protocol::Binary (petergoldstein)
95
+
96
+ 3.1.1
97
+ ==========
98
+
99
+ - Add quiet support for incr, decr, append, depend, and flush (petergoldstein)
100
+ - Additional refactoring to allow reuse of connection behavior (petergoldstein)
101
+ - Fix issue in flush such that it wasn't passing the delay argument to memcached (petergoldstein)
102
+
103
+ 3.1.0
104
+ ==========
105
+
106
+ - BREAKING CHANGE: Update Rack::Session::Dalli to inherit from Abstract::PersistedSecure. This will invalidate existing sessions (petergoldstein)
107
+ - BREAKING CHANGE: Use of unsupported operations in a multi block now raise an error. (petergoldstein)
108
+ - Extract PipelinedGetter from Dalli::Client (petergoldstein)
109
+ - Fix SSL socket so that it works with pipelined gets (petergoldstein)
110
+ - Additional refactoring to split classes (petergoldstein)
111
+
112
+ 3.0.6
113
+ ==========
114
+
115
+ - Fix regression in SASL authentication response parsing (petergoldstein)
116
+
117
+ 3.0.5
118
+ ==========
119
+
120
+ - Add Rubocop and fix most outstanding issues (petergoldstein)
121
+ - Extract a number of classes, to simplify the largest classes (petergoldstein)
122
+ - Ensure against socket corruption if an error occurs in a multi block (petergoldstein)
123
+
124
+ 3.0.4
125
+ ==========
126
+
127
+ - Clean connections and retry after NetworkError in get_multi (andrejbl)
128
+ - Internal refactoring and cleanup (petergoldstein)
129
+
130
+ 3.0.3
131
+ ==========
132
+
133
+ - Restore ability for `compress` to be disabled on a per request basis (petergoldstein)
134
+ - Fix broken image in README (deining)
135
+ - Use bundler-cache in CI (olleolleolle)
136
+ - Remove the OpenSSL extensions dependency (petergoldstein)
137
+ - Add Memcached 1.5.x to the CI matrix
138
+ - Updated compression documentation (petergoldstein)
139
+
140
+ 3.0.2
141
+ ==========
142
+
143
+ - Restore Windows compatibility (petergoldstein)
144
+ - Add JRuby to CI and make requisite changes (petergoldstein)
145
+ - Clarify documentation for supported rubies (petergoldstein)
146
+
147
+ 3.0.1
148
+ ==========
149
+
150
+ - Fix syntax error that prevented inclusion of Dalli::Server (ryanfb)
151
+ - Restore with method required by ActiveSupport::Cache::MemCacheStore
152
+
153
+ 3.0.0
154
+ ==========
155
+ - BREAKING CHANGES:
156
+
157
+ * Removes :dalli_store.
158
+ Use Rails' official :mem_cache_store instead.
159
+ https://guides.rubyonrails.org/caching_with_rails.html
160
+ * Attempting to store a larger value than allowed by memcached used to
161
+ print a warning and truncate the value. This now raises an error to
162
+ prevent silent data corruption.
163
+ * Compression now defaults to `true` for large values (greater than 4KB).
164
+ This is intended to minimize errors due to the previous note.
165
+ * Errors marshalling values now raise rather than just printing an error.
166
+ * The Rack session adapter has been refactored to remove support for thread-unsafe
167
+ configurations. You will need to include the `connection_pool` gem in
168
+ your Gemfile to ensure session operations are thread-safe.
169
+ * When using namespaces, the algorithm for calculating truncated keys was
170
+ changed. Non-truncated keys and truncated keys for the non-namespace
171
+ case were left unchanged.
172
+
173
+ - Raise NetworkError when multi response gets into corrupt state (mervync, #783)
174
+ - Validate servers argument (semaperepelitsa, petergoldstein, #776)
175
+ - Enable SSL support (bdunne, #775)
176
+ - Add gat operation (tbeauvais, #769)
177
+ - Removes inline native code, use Ruby 2.3+ support for bsearch instead. (mperham)
178
+ - Switch repo to Github Actions and upgrade Ruby versions (petergoldstein, bdunne, Fryguy)
179
+ - Update benchmark test for Rubyprof changes (nateberkopec)
180
+ - Remove support for the `kgio` gem, it is not relevant in Ruby 2.3+. (mperham)
181
+ - Remove inline native code, use Ruby 2.3+ support for bsearch instead. (mperham)
182
+
183
+
184
+ 2.7.11
185
+ ==========
186
+ - DEPRECATION: :dalli_store will be removed in Dalli 3.0.
187
+ Use Rails' official :mem_cache_store instead.
188
+ https://guides.rubyonrails.org/caching_with_rails.html
189
+ - Add new `digest_class` option to Dalli::Client [#724]
190
+ - Don't treat NameError as a network error [#728]
191
+ - Handle nested comma separated server strings (sambostock)
192
+
193
+ 2.7.10
194
+ ==========
195
+ - Revert frozen string change (schneems)
196
+ - Advertise supports_cached_versioning? in DalliStore (schneems)
197
+ - Better detection of fork support, to allow specs to run under Truffle Ruby (deepj)
198
+ - Update logging for over max size to log as error (aeroastro)
199
+
200
+ 2.7.9
201
+ ==========
202
+ - Fix behavior for Rails 5.2+ cache_versioning (GriwMF)
203
+ - Ensure fetch provides the key to the fallback block as an argument (0exp)
204
+ - Assorted performance improvements (schneems)
205
+
206
+ 2.7.8
207
+ ==========
208
+ - Rails 5.2 compatibility (pbougie)
209
+ - Fix Session Cache compatibility (pixeltrix)
210
+
211
+ 2.7.7
212
+ ==========
213
+ - Support large cache keys on fetch multi (sobrinho)
214
+ - Not found checks no longer trigger the result's equality method (dannyfallon)
215
+ - Use SVG build badges (olleolleolle)
216
+ - Travis updates (junaruga, tiarly, petergoldstein)
217
+ - Update default down_retry_delay (jaredhales)
218
+ - Close kgio socket after IO.select timeouts
219
+ - Documentation updates (tipair)
220
+ - Instrument DalliStore errors with instrument_errors configuration option. (btatnall)
221
+
4
222
  2.7.6
5
223
  ==========
6
224
  - Rails 5.0.0.beta2 compatibility (yui-knk, petergoldstein)
data/Gemfile CHANGED
@@ -1,5 +1,21 @@
1
+ # frozen_string_literal: true
2
+
1
3
  source 'https://rubygems.org'
2
4
 
3
5
  gemspec
4
6
 
5
- gem 'kgio', :platform => :mri
7
+ group :development, :test do
8
+ gem 'connection_pool'
9
+ gem 'minitest', '~> 5'
10
+ gem 'rack', '~> 2.0', '>= 2.2.0'
11
+ gem 'rake', '~> 13.0'
12
+ gem 'rubocop'
13
+ gem 'rubocop-minitest'
14
+ gem 'rubocop-performance'
15
+ gem 'rubocop-rake'
16
+ gem 'simplecov'
17
+ end
18
+
19
+ group :test do
20
+ gem 'ruby-prof', platform: :mri
21
+ end
data/README.md CHANGED
@@ -1,236 +1,56 @@
1
- Dalli [![Build Status](https://secure.travis-ci.org/petergoldstein/dalli.png)](http://travis-ci.org/petergoldstein/dalli) [![Dependency Status](https://gemnasium.com/petergoldstein/dalli.png)](https://gemnasium.com/petergoldstein/dalli) [![Code Climate](https://codeclimate.com/github/petergoldstein/dalli.png)](https://codeclimate.com/github/petergoldstein/dalli)
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. It works with memcached 1.4+ only as it uses the newer binary protocol. It should be considered a replacement for the memcache-client gem.
4
+ Dalli is a high performance pure Ruby client for accessing memcached servers.
5
5
 
6
- 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).
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
-
13
- Design
14
- ------------
15
-
16
- Mike Perham decided to write Dalli after maintaining memcache-client for two years for a few specific reasons:
17
-
18
- 0. The code is mostly old and gross. The bulk of the code is a single 1000 line .rb file.
19
- 1. It has a lot of options that are infrequently used which complicate the codebase.
20
- 2. The implementation has no single point to attach monitoring hooks.
21
- 3. Uses the old text protocol, which hurts raw performance.
22
-
23
- So a few notes. Dalli:
24
-
25
- 0. uses the exact same algorithm to choose a server so existing memcached clusters with TBs of data will work identically to memcache-client.
26
- 1. is approximately 20% faster than memcache-client (which itself was heavily optimized) in Ruby 1.9.2.
27
- 2. contains explicit "chokepoint" methods which handle all requests; these can be hooked into by monitoring tools (NewRelic, Rack::Bug, etc) to track memcached usage.
28
- 3. supports SASL for use in managed environments, e.g. Heroku.
29
- 4. provides proper failover with recovery and adjustable timeouts
30
-
31
-
32
- Supported Ruby versions and implementations
33
- ------------------------------------------------
34
-
35
- Dalli should work identically on:
36
-
37
- * JRuby 1.6+
38
- * Ruby 1.9.3+
39
- * Rubinius 2.0
40
-
41
- If you have problems, please enter an issue.
42
-
43
-
44
- Installation and Usage
45
- ------------------------
46
-
47
- 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
48
-
49
- brew install memcached
50
-
51
- On Ubuntu you can install it by running:
52
-
53
- apt-get install memcached
54
-
55
- You can verify your installation using this piece of code:
56
-
57
- ```bash
58
- gem install dalli
59
- ```
60
-
61
- ```ruby
62
- require 'dalli'
63
- options = { :namespace => "app_v1", :compress => true }
64
- dc = Dalli::Client.new('localhost:11211', options)
65
- dc.set('abc', 123)
66
- value = dc.get('abc')
67
- ```
68
-
69
- 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.
70
-
71
- Dalli has no runtime dependencies and never will. You can optionally install the 'kgio' gem to
72
- give Dalli a 20-30% performance boost.
73
-
74
-
75
- Usage with Rails 3.x and 4.x
76
- ---------------------------
77
-
78
- In your Gemfile:
79
-
80
- ```ruby
81
- gem 'dalli'
82
- ```
83
-
84
- In `config/environments/production.rb`:
85
-
86
- ```ruby
87
- config.cache_store = :dalli_store
88
- ```
89
-
90
- Here's a more comprehensive example that sets a reasonable default for maximum cache entry lifetime (one day), enables compression for large values and namespaces all entries for this rails app. Remove the namespace if you have multiple apps which share cached values.
91
-
92
- ```ruby
93
- config.cache_store = :dalli_store, 'cache-1.example.com', 'cache-2.example.com',
94
- { :namespace => NAME_OF_RAILS_APP, :expires_in => 1.day, :compress => true }
95
- ```
96
-
97
- If your servers are specified in `ENV["MEMCACHE_SERVERS"]` (e.g. on Heroku when using a third-party hosted addon), simply provide `nil` for the servers:
98
-
99
- ```ruby
100
- config.cache_store = :dalli_store, nil, { :namespace => NAME_OF_RAILS_APP, :expires_in => 1.day, :compress => true }
101
- ```
6
+ Dalli supports:
102
7
 
103
- To use Dalli for Rails session storage that times out after 20 minutes, in `config/initializers/session_store.rb`:
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
104
14
 
105
- For Rails >= 3.2.4:
106
-
107
- ```ruby
108
- Rails.application.config.session_store ActionDispatch::Session::CacheStore, :expire_after => 20.minutes
109
- ```
110
-
111
- For Rails 3.x:
112
-
113
- ```ruby
114
- require 'action_dispatch/middleware/session/dalli_store'
115
- Rails.application.config.session_store :dalli_store, :memcache_server => ['host1', 'host2'], :namespace => 'sessions', :key => '_foundation_session', :expire_after => 20.minutes
116
- ```
117
-
118
- Dalli does not support Rails 2.x.
119
-
120
-
121
- Multithreading and Rails
122
- --------------------------
123
-
124
- If you use Puma or another threaded app server, as of Dalli 2.7, you can use a pool
125
- of Dalli clients with Rails to ensure the `Rails.cache` singleton does not become a
126
- source of thread contention. You must add `gem 'connection_pool'` to your Gemfile and
127
- add :pool\_size to your `dalli_store` config:
128
-
129
- ```ruby
130
- config.cache_store = :dalli_store, 'cache-1.example.com', { :pool_size => 5 }
131
- ```
132
-
133
- You can then use the Rails cache as normal and Rails.cache will use the pool transparently under the covers, or you can check out a Dalli client directly from the pool:
134
-
135
- ```ruby
136
- Rails.cache.fetch('foo', :expires_in => 300) do
137
- 'bar'
138
- end
139
-
140
- Rails.cache.dalli.with do |client|
141
- # client is a Dalli::Client instance which you can
142
- # use ONLY within this block
143
- end
144
- ```
145
-
146
-
147
- Configuration
148
- ------------------------
149
-
150
- Dalli::Client accepts the following options. All times are in seconds.
151
-
152
- **expires_in**: Global default for key TTL. Default is 0, which means no expiry.
153
-
154
- **namespace**: If specified, prepends each key with this value to provide simple namespacing. Default is nil.
155
-
156
- **failover**: Boolean, if true Dalli will failover to another server if the main server for a key is down. Default is true.
157
-
158
- **threadsafe**: Boolean. If true Dalli ensures that only one thread is using a socket at a given time. Default is true. Set to false at your own peril.
159
-
160
- **serializer**: The serializer to use for objects being stored (ex. JSON).
161
- Default is Marshal.
162
-
163
- **compress**: Boolean, if true Dalli will gzip-compress values larger than 1K. Default is false.
164
-
165
- **compression_min_size**: Minimum value byte size for which to attempt compression. Default is 1K.
166
-
167
- **compression_max_size**: Maximum value byte size for which to attempt compression. Default is unlimited.
168
-
169
- **compressor**: The compressor to use for objects being stored.
170
- Default is zlib, implemented under `Dalli::Compressor`.
171
- If serving compressed data using nginx's HttpMemcachedModule, set `memcached_gzip_flag 2` and use `Dalli::GzipCompressor`
172
-
173
- **keepalive**: Boolean. If true, Dalli will enable keep-alive for socket connections. Default is true.
174
-
175
- **socket_timeout**: Timeout for all socket operations (connect, read, write). Default is 0.5.
176
-
177
- **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.
178
-
179
- **socket_failure_delay**: Before retrying a socket operation, the process sleeps for this amount of time. Default is 0.01. Set to nil for no delay.
180
-
181
- **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 1 second.
182
-
183
- **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.
184
-
185
- **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.
186
-
187
- **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.
188
-
189
- **sndbuf**: In bytes, set the socket SO_SNDBUF. Defaults to operating system default.
190
-
191
- **rcvbuf**: In bytes, set the socket SO_RCVBUF. Defaults to operating system default.
192
-
193
- **cache_nils**: Boolean. If true Dalli will not treat cached `nil` values as 'not found' for `#fetch` operations. Default is false.
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).
194
16
 
195
- Features and Changes
196
- ------------------------
17
+ ![Persistence of Memory](https://upload.wikimedia.org/wikipedia/en/d/dd/The_Persistence_of_Memory.jpg)
197
18
 
198
- By default, Dalli is thread-safe. Disable thread-safety at your own peril.
199
19
 
200
- Dalli does not need anything special in Unicorn/Passenger since 2.0.4.
201
- It will detect sockets shared with child processes and gracefully reopen the
202
- socket.
20
+ ## Documentation and Information
203
21
 
204
- Note that Dalli does not require ActiveSupport or Rails. You can safely use it in your own Ruby projects.
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/gems/dalli) - Ruby documentation for the `Dalli::Client` API
205
27
 
206
- [View the Client API](http://www.rubydoc.info/github/mperham/dalli/Dalli/Client)
28
+ ## Development
207
29
 
208
- Helping Out
209
- -------------
30
+ After checking out the repo, run `bin/setup` to install dependencies. You can run `bin/console` for an interactive prompt that will allow you to experiment.
210
31
 
211
- 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.
32
+ To install this gem onto your local machine, run `bundle exec rake install`.
212
33
 
213
- We're not accepting new compressors. They are trivial to add in an initializer. See #385 (LZ4), #406 (Snappy)
34
+ ## Contributing
214
35
 
215
- Thanks
216
- ------------
36
+ 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 the [changelog](CHANGELOG.md) with a one sentence description of your fix so you get credit as a contributor.
217
37
 
218
- Mike Perham - for originally authoring the Dalli project and serving as maintainer and primary contributor
38
+ ## Appreciation
219
39
 
220
- Eric Wong - for help using his [kgio](http://bogomips.org/kgio/) library.
40
+ Dalli would not exist in its current form without the contributions of many people. But special thanks go to several individuals and organizations:
221
41
 
222
- Brian Mitchell - for his remix-stash project which was helpful when implementing and testing the binary protocol support.
42
+ * Mike Perham - for originally authoring the Dalli project and serving as maintainer and primary contributor for many years
43
+ * Eric Wong - for help using his [kgio](http://bogomips.org/kgio/) library.
44
+ * Brian Mitchell - for his remix-stash project which was helpful when implementing and testing the binary protocol support.
45
+ * [CouchBase](http://couchbase.com) - for their sponsorship of the original development
223
46
 
224
- [CouchBase](http://couchbase.com) - for their project sponsorship
225
47
 
226
- Authors
227
- ----------
48
+ ## Authors
228
49
 
229
50
  * [Peter M. Goldstein](https://github.com/petergoldstein) - current maintainer
230
51
  * [Mike Perham](https://github.com/mperham) and contributors
231
52
 
232
53
 
233
- Copyright
234
- -----------
54
+ ## Copyright
235
55
 
236
56
  Copyright (c) Mike Perham, Peter M. Goldstein. See LICENSE for details.
@@ -1,58 +1,3 @@
1
- require 'dalli/client'
1
+ # frozen_string_literal: true
2
2
 
3
- module Dalli
4
- class Client
5
- ##
6
- # Get the value and CAS ID associated with the key. If a block is provided,
7
- # value and CAS will be passed to the block.
8
- def get_cas(key)
9
- (value, cas) = perform(:cas, key)
10
- value = (!value || value == 'Not found') ? nil : value
11
- if block_given?
12
- yield value, cas
13
- else
14
- [value, cas]
15
- end
16
- end
17
-
18
- ##
19
- # Fetch multiple keys efficiently, including available metadata such as CAS.
20
- # If a block is given, yields key/data pairs one a time. Data is an array:
21
- # [value, cas_id]
22
- # If no block is given, returns a hash of
23
- # { 'key' => [value, cas_id] }
24
- def get_multi_cas(*keys)
25
- if block_given?
26
- get_multi_yielder(keys) {|*args| yield(*args)}
27
- else
28
- Hash.new.tap do |hash|
29
- get_multi_yielder(keys) {|k, data| hash[k] = data}
30
- end
31
- end
32
- end
33
-
34
- ##
35
- # Set the key-value pair, verifying existing CAS.
36
- # Returns the resulting CAS value if succeeded, and falsy otherwise.
37
- def set_cas(key, value, cas, ttl=nil, options=nil)
38
- ttl ||= @options[:expires_in].to_i
39
- perform(:set, key, value, ttl, cas, options)
40
- end
41
-
42
- ##
43
- # Conditionally add a key/value pair, verifying existing CAS, only if the
44
- # key already exists on the server. Returns the new CAS value if the
45
- # operation succeeded, or falsy otherwise.
46
- def replace_cas(key, value, cas, ttl=nil, options=nil)
47
- ttl ||= @options[:expires_in].to_i
48
- perform(:replace, key, value, ttl, cas, options)
49
- end
50
-
51
- # Delete a key/value pair, verifying existing CAS.
52
- # Returns true if succeeded, and falsy otherwise.
53
- def delete_cas(key, cas=0)
54
- perform(:delete, key, cas)
55
- end
56
-
57
- end
58
- end
3
+ puts "You can remove `require 'dalli/cas/client'` as this code has been rolled into the standard 'dalli/client'."