dalli 2.7.10 → 3.2.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (40) hide show
  1. checksums.yaml +4 -4
  2. data/{History.md → CHANGELOG.md} +163 -2
  3. data/Gemfile +17 -1
  4. data/README.md +30 -221
  5. data/lib/dalli/cas/client.rb +1 -57
  6. data/lib/dalli/client.rb +226 -258
  7. data/lib/dalli/compressor.rb +12 -2
  8. data/lib/dalli/key_manager.rb +121 -0
  9. data/lib/dalli/options.rb +6 -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 +239 -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 +254 -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 +8 -0
  30. data/lib/dalli/ring.rb +94 -83
  31. data/lib/dalli/server.rb +3 -746
  32. data/lib/dalli/servers_arg_normalizer.rb +54 -0
  33. data/lib/dalli/socket.rb +117 -137
  34. data/lib/dalli/version.rb +4 -1
  35. data/lib/dalli.rb +43 -15
  36. data/lib/rack/session/dalli.rb +103 -94
  37. metadata +34 -127
  38. data/lib/action_dispatch/middleware/session/dalli_store.rb +0 -82
  39. data/lib/active_support/cache/dalli_store.rb +0 -435
  40. data/lib/dalli/railtie.rb +0 -8
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4777faf19b3b49b1594e2c07154e7e9a604301349b3a3bcc1b7b8f790533011e
4
- data.tar.gz: 0e19dc281dae4f0bb59d1282c8f530a891edaba56c8e09737b43490b55f14660
3
+ metadata.gz: e182f80ca3d5c567c59e32d7396f0c347ad79633672af15d6f231950909f12dd
4
+ data.tar.gz: 92ddb5854da64ce59fb07c2eae7e1c1ce94d36868d26776c6415d20569dc0466
5
5
  SHA512:
6
- metadata.gz: 846fc9de820119477c1a5a79749367b26ae59e3212d074023df61db3d497f0f71022acc47b461294f028ab79e26d0ecb467630cfbd7f54923a7fc66a3d9c340f
7
- data.tar.gz: 49c05acb4e93a77edf47c140ae3bc46995e42eb65238e151b81908c48653422b4364f960aa7abefa9653de0544aa05e28351e2fce883c4855a376d2f8c42cd2f
6
+ metadata.gz: 89b2f797e3abe759ddb154c10c91cfe4126341c0bd95202637e8ff67845a02669e0be4cdfc486679e45322f31976b41a404f7223b03042107aab8db3011414c5
7
+ data.tar.gz: 4bc8eb1c4b478b946e202709d9d20995ebcb894ab32b5be070a19f99cecdfbd5ff0219344fe7288710202159a1b33298c1408e878a39cf256086f892ea5c4d41
@@ -1,12 +1,173 @@
1
1
  Dalli Changelog
2
2
  =====================
3
3
 
4
+ Unreleased
5
+ ==========
6
+
7
+ 3.2.4
8
+ ==========
9
+
10
+ - Cache PID calls for performance since glibc no longer caches in recent versions (casperisfine)
11
+ - Preallocate the read buffer in Socket#readfull (casperisfine)
12
+
13
+ 3.2.3
14
+ ==========
15
+
16
+ - Sanitize CAS inputs to ensure additional commands are not passed to memcached (xhzeem / petergoldstein)
17
+ - Sanitize input to flush command to ensure additional commands are not passed to memcached (xhzeem / petergoldstein)
18
+ - Namespaces passed as procs are now evaluated every time, as opposed to just on initialization (nrw505)
19
+ - Fix missing require of uri in ServerConfigParser (adam12)
20
+ - Fix link to the CHANGELOG.md file in README.md (rud)
21
+
22
+ 3.2.2
23
+ ==========
24
+
25
+ - Ensure apps are resilient against old session ids (kbrock)
26
+
27
+ 3.2.1
28
+ ==========
29
+
30
+ - Fix null replacement bug on some SASL-authenticated services (veritas1)
31
+
32
+ 3.2.0
33
+ ==========
34
+
35
+ - BREAKING CHANGE: Remove protocol_implementation client option (petergoldstein)
36
+ - Add protocol option with meta implementation (petergoldstein)
37
+
38
+ 3.1.6
39
+ ==========
40
+
41
+ - Fix bug with cas/cas! with "Not found" value (petergoldstein)
42
+ - Add Ruby 3.1 to CI (petergoldstein)
43
+ - Replace reject(&:nil?) with compact (petergoldstein)
44
+
45
+ 3.1.5
46
+ ==========
47
+
48
+ - Fix bug with get_cas key with "Not found" value (petergoldstein)
49
+ - Replace should return nil, not raise error, on miss (petergoldstein)
50
+
51
+ 3.1.4
52
+ ==========
53
+
54
+ - Improve response parsing performance (casperisfine)
55
+ - Reorganize binary protocol parsing a bit (petergoldstein)
56
+ - Fix handling of non-ASCII keys in get_multi (petergoldstein)
57
+
58
+ 3.1.3
59
+ ==========
60
+
61
+ - Restore falsey behavior on delete/delete_cas for nonexistent key (petergoldstein)
62
+
63
+ 3.1.2
64
+ ==========
65
+
66
+ - Make quiet? / multi? public on Dalli::Protocol::Binary (petergoldstein)
67
+
68
+ 3.1.1
69
+ ==========
70
+
71
+ - Add quiet support for incr, decr, append, depend, and flush (petergoldstein)
72
+ - Additional refactoring to allow reuse of connection behavior (petergoldstein)
73
+ - Fix issue in flush such that it wasn't passing the delay argument to memcached (petergoldstein)
74
+
75
+ 3.1.0
76
+ ==========
77
+
78
+ - BREAKING CHANGE: Update Rack::Session::Dalli to inherit from Abstract::PersistedSecure. This will invalidate existing sessions (petergoldstein)
79
+ - BREAKING CHANGE: Use of unsupported operations in a multi block now raise an error. (petergoldstein)
80
+ - Extract PipelinedGetter from Dalli::Client (petergoldstein)
81
+ - Fix SSL socket so that it works with pipelined gets (petergoldstein)
82
+ - Additional refactoring to split classes (petergoldstein)
83
+
84
+ 3.0.6
85
+ ==========
86
+
87
+ - Fix regression in SASL authentication response parsing (petergoldstein)
88
+
89
+ 3.0.5
90
+ ==========
91
+
92
+ - Add Rubocop and fix most outstanding issues (petergoldstein)
93
+ - Extract a number of classes, to simplify the largest classes (petergoldstein)
94
+ - Ensure against socket corruption if an error occurs in a multi block (petergoldstein)
95
+
96
+ 3.0.4
97
+ ==========
98
+
99
+ - Clean connections and retry after NetworkError in get_multi (andrejbl)
100
+ - Internal refactoring and cleanup (petergoldstein)
101
+
102
+ 3.0.3
103
+ ==========
104
+
105
+ - Restore ability for `compress` to be disabled on a per request basis (petergoldstein)
106
+ - Fix broken image in README (deining)
107
+ - Use bundler-cache in CI (olleolleolle)
108
+ - Remove the OpenSSL extensions dependency (petergoldstein)
109
+ - Add Memcached 1.5.x to the CI matrix
110
+ - Updated compression documentation (petergoldstein)
111
+
112
+ 3.0.2
113
+ ==========
114
+
115
+ - Restore Windows compatibility (petergoldstein)
116
+ - Add JRuby to CI and make requisite changes (petergoldstein)
117
+ - Clarify documentation for supported rubies (petergoldstein)
118
+
119
+ 3.0.1
120
+ ==========
121
+
122
+ - Fix syntax error that prevented inclusion of Dalli::Server (ryanfb)
123
+ - Restore with method required by ActiveSupport::Cache::MemCacheStore
124
+
125
+ 3.0.0
126
+ ==========
127
+ - BREAKING CHANGES:
128
+
129
+ * Removes :dalli_store.
130
+ Use Rails' official :mem_cache_store instead.
131
+ https://guides.rubyonrails.org/caching_with_rails.html
132
+ * Attempting to store a larger value than allowed by memcached used to
133
+ print a warning and truncate the value. This now raises an error to
134
+ prevent silent data corruption.
135
+ * Compression now defaults to `true` for large values (greater than 4KB).
136
+ This is intended to minimize errors due to the previous note.
137
+ * Errors marshalling values now raise rather than just printing an error.
138
+ * The Rack session adapter has been refactored to remove support for thread-unsafe
139
+ configurations. You will need to include the `connection_pool` gem in
140
+ your Gemfile to ensure session operations are thread-safe.
141
+ * When using namespaces, the algorithm for calculating truncated keys was
142
+ changed. Non-truncated keys and truncated keys for the non-namespace
143
+ case were left unchanged.
144
+
145
+ - Raise NetworkError when multi response gets into corrupt state (mervync, #783)
146
+ - Validate servers argument (semaperepelitsa, petergoldstein, #776)
147
+ - Enable SSL support (bdunne, #775)
148
+ - Add gat operation (tbeauvais, #769)
149
+ - Removes inline native code, use Ruby 2.3+ support for bsearch instead. (mperham)
150
+ - Switch repo to Github Actions and upgrade Ruby versions (petergoldstein, bdunne, Fryguy)
151
+ - Update benchmark test for Rubyprof changes (nateberkopec)
152
+ - Remove support for the `kgio` gem, it is not relevant in Ruby 2.3+. (mperham)
153
+ - Remove inline native code, use Ruby 2.3+ support for bsearch instead. (mperham)
154
+
155
+
156
+ 2.7.11
157
+ ==========
158
+ - DEPRECATION: :dalli_store will be removed in Dalli 3.0.
159
+ Use Rails' official :mem_cache_store instead.
160
+ https://guides.rubyonrails.org/caching_with_rails.html
161
+ - Add new `digest_class` option to Dalli::Client [#724]
162
+ - Don't treat NameError as a network error [#728]
163
+ - Handle nested comma separated server strings (sambostock)
164
+
4
165
  2.7.10
5
166
  ==========
6
167
  - Revert frozen string change (schneems)
7
168
  - Advertise supports_cached_versioning? in DalliStore (schneems)
8
- - Better detection of fork support, to allow specs to run under Truffle Ruby
9
- - Update logging for over max size to log as error
169
+ - Better detection of fork support, to allow specs to run under Truffle Ruby (deepj)
170
+ - Update logging for over max size to log as error (aeroastro)
10
171
 
11
172
  2.7.9
12
173
  ==========
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,247 +1,56 @@
1
- Dalli [![Build Status](https://secure.travis-ci.org/petergoldstein/dalli.svg)](http://travis-ci.org/petergoldstein/dalli) [![Dependency Status](https://gemnasium.com/petergoldstein/dalli.svg)](https://gemnasium.com/petergoldstein/dalli) [![Code Climate](https://codeclimate.com/github/petergoldstein/dalli.svg)](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. If you are using Ruby <2.3,
72
- you can optionally install the '[kgio](https://bogomips.org/kgio/)' gem to
73
- give Dalli a 20-30% performance boost.
74
-
75
-
76
- Usage with Rails 3.x and 4.x
77
- ---------------------------
78
-
79
- In your Gemfile:
80
-
81
- ```ruby
82
- gem 'dalli'
83
- ```
84
-
85
- In `config/environments/production.rb`:
86
-
87
- ```ruby
88
- config.cache_store = :dalli_store
89
- ```
90
-
91
- 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.
92
-
93
- ```ruby
94
- config.cache_store = :dalli_store, 'cache-1.example.com', 'cache-2.example.com:11211:2',
95
- { :namespace => NAME_OF_RAILS_APP, :expires_in => 1.day, :compress => true }
96
- ```
97
-
98
- You can specify a port and a weight by appending to the server name. You may wish to increase the weight of a server with more memory configured. (e.g. to specify port 11211 and a weight of 2, append `:11211:2` )
99
-
100
- 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:
101
-
102
- ```ruby
103
- config.cache_store = :dalli_store, nil, { :namespace => NAME_OF_RAILS_APP, :expires_in => 1.day, :compress => true }
104
- ```
105
-
106
- To use Dalli for Rails session storage that times out after 20 minutes, in `config/initializers/session_store.rb`:
107
-
108
- For Rails >= 3.2.4:
6
+ Dalli supports:
109
7
 
110
- ```ruby
111
- Rails.application.config.session_store ActionDispatch::Session::CacheStore, :expire_after => 20.minutes
112
- ```
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
113
14
 
114
- For Rails 3.x:
115
-
116
- ```ruby
117
- require 'action_dispatch/middleware/session/dalli_store'
118
- Rails.application.config.session_store :dalli_store, :memcache_server => ['host1', 'host2'], :namespace => 'sessions', :key => '_foundation_session', :expire_after => 20.minutes
119
- ```
120
-
121
- Dalli does not support Rails 2.x.
122
-
123
-
124
- Multithreading and Rails
125
- --------------------------
126
-
127
- If you use Puma or another threaded app server, as of Dalli 2.7, you can use a pool
128
- of Dalli clients with Rails to ensure the `Rails.cache` singleton does not become a
129
- source of thread contention. You must add `gem 'connection_pool'` to your Gemfile and
130
- add :pool\_size to your `dalli_store` config:
131
-
132
- ```ruby
133
- config.cache_store = :dalli_store, 'cache-1.example.com', { :pool_size => 5 }
134
- ```
135
-
136
- 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:
137
-
138
- ```ruby
139
- Rails.cache.fetch('foo', :expires_in => 300) do
140
- 'bar'
141
- end
142
-
143
- Rails.cache.dalli.with do |client|
144
- # client is a Dalli::Client instance which you can
145
- # use ONLY within this block
146
- end
147
- ```
148
-
149
-
150
- Configuration
151
- ------------------------
152
-
153
- **servers**: An Array of "host:port:weight" where weight allows you to distribute cache unevenly.
154
-
155
- Dalli::Client accepts the following options. All times are in seconds.
156
-
157
- **expires_in**: Global default for key TTL. Default is 0, which means no expiry.
158
-
159
- **namespace**: If specified, prepends each key with this value to provide simple namespacing. Default is nil.
160
-
161
- **failover**: Boolean, if true Dalli will failover to another server if the main server for a key is down. Default is true.
162
-
163
- **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.
164
-
165
- **serializer**: The serializer to use for objects being stored (ex. JSON).
166
- Default is Marshal.
167
-
168
- **compress**: Boolean, if true Dalli will gzip-compress values larger than 1K. Default is false.
169
-
170
- **compression_min_size**: Minimum value byte size for which to attempt compression. Default is 1K.
171
-
172
- **compression_max_size**: Maximum value byte size for which to attempt compression. Default is unlimited.
173
-
174
- **compressor**: The compressor to use for objects being stored.
175
- Default is zlib, implemented under `Dalli::Compressor`.
176
- If serving compressed data using nginx's HttpMemcachedModule, set `memcached_gzip_flag 2` and use `Dalli::GzipCompressor`
177
-
178
- **keepalive**: Boolean. If true, Dalli will enable keep-alive for socket connections. Default is true.
179
-
180
- **socket_timeout**: Timeout for all socket operations (connect, read, write). Default is 0.5.
181
-
182
- **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.
183
-
184
- **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.
185
-
186
- **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 60 seconds.
187
-
188
- **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.
189
-
190
- **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.
191
-
192
- **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.
193
-
194
- **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.
195
-
196
- **sndbuf**: In bytes, set the socket SO_SNDBUF. Defaults to operating system default.
197
-
198
- **rcvbuf**: In bytes, set the socket SO_RCVBUF. Defaults to operating system default.
199
-
200
- **cache_nils**: Boolean. If true Dalli will not treat cached `nil` values as 'not found' for `#fetch` operations. Default is false.
201
-
202
- **raise_errors**: Boolean. When true DalliStore will reraise Dalli:DalliError instead swallowing the error. Default is false.
203
-
204
- **instrument_errors**: Boolean. When true DalliStore will send notification of Dalli::DalliError via a 'cache_error.active_support' event. 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).
205
16
 
206
- Features and Changes
207
- ------------------------
17
+ ![Persistence of Memory](https://upload.wikimedia.org/wikipedia/en/d/dd/The_Persistence_of_Memory.jpg)
208
18
 
209
- By default, Dalli is thread-safe. Disable thread-safety at your own peril.
210
19
 
211
- Dalli does not need anything special in Unicorn/Passenger since 2.0.4.
212
- It will detect sockets shared with child processes and gracefully reopen the
213
- socket.
20
+ ## Documentation and Information
214
21
 
215
- 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://rubydoc.info/github/petergoldstein/dalli/Dalli/Client) - Ruby documentation for the `Dalli::Client` API
216
27
 
217
- [View the Client API](http://www.rubydoc.info/github/mperham/dalli/Dalli/Client)
28
+ ## Development
218
29
 
219
- Helping Out
220
- -------------
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.
221
31
 
222
- 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`.
223
33
 
224
- We're not accepting new compressors. They are trivial to add in an initializer. See #385 (LZ4), #406 (Snappy)
34
+ ## Contributing
225
35
 
226
- Thanks
227
- ------------
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.
228
37
 
229
- Mike Perham - for originally authoring the Dalli project and serving as maintainer and primary contributor
38
+ ## Appreciation
230
39
 
231
- 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:
232
41
 
233
- 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
234
46
 
235
- [CouchBase](http://couchbase.com) - for their project sponsorship
236
47
 
237
- Authors
238
- ----------
48
+ ## Authors
239
49
 
240
50
  * [Peter M. Goldstein](https://github.com/petergoldstein) - current maintainer
241
51
  * [Mike Perham](https://github.com/mperham) and contributors
242
52
 
243
53
 
244
- Copyright
245
- -----------
54
+ ## Copyright
246
55
 
247
56
  Copyright (c) Mike Perham, Peter M. Goldstein. See LICENSE for details.
@@ -1,59 +1,3 @@
1
1
  # frozen_string_literal: true
2
- require 'dalli/client'
3
2
 
4
- module Dalli
5
- class Client
6
- ##
7
- # Get the value and CAS ID associated with the key. If a block is provided,
8
- # value and CAS will be passed to the block.
9
- def get_cas(key)
10
- (value, cas) = perform(:cas, key)
11
- value = (!value || value == 'Not found') ? nil : value
12
- if block_given?
13
- yield value, cas
14
- else
15
- [value, cas]
16
- end
17
- end
18
-
19
- ##
20
- # Fetch multiple keys efficiently, including available metadata such as CAS.
21
- # If a block is given, yields key/data pairs one a time. Data is an array:
22
- # [value, cas_id]
23
- # If no block is given, returns a hash of
24
- # { 'key' => [value, cas_id] }
25
- def get_multi_cas(*keys)
26
- if block_given?
27
- get_multi_yielder(keys) {|*args| yield(*args)}
28
- else
29
- Hash.new.tap do |hash|
30
- get_multi_yielder(keys) {|k, data| hash[k] = data}
31
- end
32
- end
33
- end
34
-
35
- ##
36
- # Set the key-value pair, verifying existing CAS.
37
- # Returns the resulting CAS value if succeeded, and falsy otherwise.
38
- def set_cas(key, value, cas, ttl=nil, options=nil)
39
- ttl ||= @options[:expires_in].to_i
40
- perform(:set, key, value, ttl, cas, options)
41
- end
42
-
43
- ##
44
- # Conditionally add a key/value pair, verifying existing CAS, only if the
45
- # key already exists on the server. Returns the new CAS value if the
46
- # operation succeeded, or falsy otherwise.
47
- def replace_cas(key, value, cas, ttl=nil, options=nil)
48
- ttl ||= @options[:expires_in].to_i
49
- perform(:replace, key, value, ttl, cas, options)
50
- end
51
-
52
- # Delete a key/value pair, verifying existing CAS.
53
- # Returns true if succeeded, and falsy otherwise.
54
- def delete_cas(key, cas=0)
55
- perform(:delete, key, cas)
56
- end
57
-
58
- end
59
- end
3
+ puts "You can remove `require 'dalli/cas/client'` as this code has been rolled into the standard 'dalli/client'."