dalli 2.7.0 → 3.0.4
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 +5 -5
- data/Gemfile +5 -7
- data/History.md +151 -0
- data/LICENSE +1 -1
- data/README.md +56 -102
- data/lib/dalli/cas/client.rb +1 -58
- data/lib/dalli/client.rb +263 -139
- data/lib/dalli/compressor.rb +5 -3
- data/lib/dalli/options.rb +4 -4
- data/lib/dalli/protocol/binary.rb +703 -0
- data/lib/dalli/protocol/server_config_parser.rb +67 -0
- data/lib/dalli/protocol/ttl_sanitizer.rb +45 -0
- data/lib/dalli/protocol/value_compressor.rb +85 -0
- data/lib/dalli/protocol.rb +9 -0
- data/lib/dalli/ring.rb +17 -68
- data/lib/dalli/server.rb +3 -689
- data/lib/dalli/socket.rb +79 -83
- data/lib/dalli/version.rb +3 -1
- data/lib/dalli.rb +20 -16
- data/lib/rack/session/dalli.rb +124 -30
- metadata +33 -77
- data/Performance.md +0 -42
- data/Rakefile +0 -42
- data/dalli.gemspec +0 -29
- data/lib/action_dispatch/middleware/session/dalli_store.rb +0 -81
- data/lib/active_support/cache/dalli_store.rb +0 -361
- data/lib/dalli/railtie.rb +0 -7
- data/test/benchmark_test.rb +0 -242
- data/test/helper.rb +0 -55
- data/test/memcached_mock.rb +0 -121
- data/test/sasldb +0 -1
- data/test/test_active_support.rb +0 -427
- data/test/test_cas_client.rb +0 -107
- data/test/test_compressor.rb +0 -53
- data/test/test_dalli.rb +0 -601
- data/test/test_encoding.rb +0 -32
- data/test/test_failover.rb +0 -128
- data/test/test_network.rb +0 -54
- data/test/test_rack_session.rb +0 -321
- data/test/test_ring.rb +0 -85
- data/test/test_sasl.rb +0 -110
- data/test/test_serializer.rb +0 -30
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: de12f6f4e7e074752c4b3d2ccaa24450fd081e6e4ded890c632158858e5aa939
|
4
|
+
data.tar.gz: '01093957dc00b0742995b5d9198014dc480bd08788f4f3c2e5160cd2a6ca8725'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c073d5ce9922b8617c11c507b8b90603ccdf304419c2fe395af33467f880c75e4a22e9e5e6eae387c78ae937b6b8de5d68eba87b323967cce03a8aaffeeba1d8
|
7
|
+
data.tar.gz: f7fd88ee88a887c44a1b94d0e3c6c7b0d210d08c38db39ea387585a18a82c5cd0a4e9a57daaa444e927e4c47f81fbd404daeec139ded6d8ff6d39fe3e565022d
|
data/Gemfile
CHANGED
@@ -1,12 +1,10 @@
|
|
1
|
-
source
|
1
|
+
source "https://rubygems.org"
|
2
2
|
|
3
3
|
gemspec
|
4
4
|
|
5
|
-
gem 'rake'
|
6
|
-
gem 'kgio', :platform => :mri
|
7
|
-
gem 'appraisal'
|
8
|
-
gem 'connection_pool'
|
9
|
-
|
10
5
|
group :test do
|
11
|
-
gem
|
6
|
+
gem "minitest"
|
7
|
+
gem "rake"
|
8
|
+
gem "simplecov"
|
9
|
+
gem "ruby-prof", platform: :mri
|
12
10
|
end
|
data/History.md
CHANGED
@@ -1,9 +1,160 @@
|
|
1
1
|
Dalli Changelog
|
2
2
|
=====================
|
3
3
|
|
4
|
+
3.0.4
|
5
|
+
==========
|
6
|
+
|
7
|
+
- Clean connections and retry after NetworkError in get_multi (andrejbl)
|
8
|
+
- Internal refactoring and cleanup (petergoldstein)
|
9
|
+
|
10
|
+
3.0.3
|
11
|
+
==========
|
12
|
+
|
13
|
+
- Restore ability for `compress` to be disabled on a per request basis (petergoldstein)
|
14
|
+
- Fix broken image in README (deining)
|
15
|
+
- Use bundler-cache in CI (olleolleolle)
|
16
|
+
- Remove the OpenSSL extensions dependency (petergoldstein)
|
17
|
+
- Add Memcached 1.5.x to the CI matrix
|
18
|
+
- Updated compression documentation (petergoldstein)
|
19
|
+
|
20
|
+
3.0.2
|
21
|
+
==========
|
22
|
+
|
23
|
+
- Restore Windows compatibility (petergoldstein)
|
24
|
+
- Add JRuby to CI and make requisite changes (petergoldstein)
|
25
|
+
- Clarify documentation for supported rubies (petergoldstein)
|
26
|
+
|
27
|
+
3.0.1
|
28
|
+
==========
|
29
|
+
|
30
|
+
- Fix syntax error that prevented inclusion of Dalli::Server (ryanfb)
|
31
|
+
- Restore with method required by ActiveSupport::Cache::MemCacheStore
|
32
|
+
|
33
|
+
3.0.0
|
34
|
+
==========
|
35
|
+
- BREAKING CHANGES:
|
36
|
+
|
37
|
+
* Removes :dalli_store.
|
38
|
+
Use Rails' official :mem_cache_store instead.
|
39
|
+
https://guides.rubyonrails.org/caching_with_rails.html
|
40
|
+
* Attempting to store a larger value than allowed by memcached used to
|
41
|
+
print a warning and truncate the value. This now raises an error to
|
42
|
+
prevent silent data corruption.
|
43
|
+
* Compression now defaults to `true` for large values (greater than 4KB).
|
44
|
+
This is intended to minimize errors due to the previous note.
|
45
|
+
* Errors marshalling values now raise rather than just printing an error.
|
46
|
+
* The Rack session adapter has been refactored to remove support for thread-unsafe
|
47
|
+
configurations. You will need to include the `connection_pool` gem in
|
48
|
+
your Gemfile to ensure session operations are thread-safe.
|
49
|
+
|
50
|
+
- Raise NetworkError when multi response gets into corrupt state (mervync, #783)
|
51
|
+
- Validate servers argument (semaperepelitsa, petergoldstein, #776)
|
52
|
+
- Enable SSL support (bdunne, #775)
|
53
|
+
- Add gat operation (tbeauvais, #769)
|
54
|
+
- Removes inline native code, use Ruby 2.3+ support for bsearch instead. (mperham)
|
55
|
+
- Switch repo to Github Actions and upgrade Ruby versions (petergoldstein, bdunne, Fryguy)
|
56
|
+
- Update benchmark test for Rubyprof changes (nateberkopec)
|
57
|
+
- Remove support for the `kgio` gem, it is not relevant in Ruby 2.3+. (mperham)
|
58
|
+
- Remove inline native code, use Ruby 2.3+ support for bsearch instead. (mperham)
|
59
|
+
|
60
|
+
|
61
|
+
2.7.11
|
62
|
+
==========
|
63
|
+
- DEPRECATION: :dalli_store will be removed in Dalli 3.0.
|
64
|
+
Use Rails' official :mem_cache_store instead.
|
65
|
+
https://guides.rubyonrails.org/caching_with_rails.html
|
66
|
+
- Add new `digest_class` option to Dalli::Client [#724]
|
67
|
+
- Don't treat NameError as a network error [#728]
|
68
|
+
- Handle nested comma separated server strings (sambostock)
|
69
|
+
|
70
|
+
2.7.10
|
71
|
+
==========
|
72
|
+
- Revert frozen string change (schneems)
|
73
|
+
- Advertise supports_cached_versioning? in DalliStore (schneems)
|
74
|
+
- Better detection of fork support, to allow specs to run under Truffle Ruby (deepj)
|
75
|
+
- Update logging for over max size to log as error (aeroastro)
|
76
|
+
|
77
|
+
2.7.9
|
78
|
+
==========
|
79
|
+
- Fix behavior for Rails 5.2+ cache_versioning (GriwMF)
|
80
|
+
- Ensure fetch provides the key to the fallback block as an argument (0exp)
|
81
|
+
- Assorted performance improvements (schneems)
|
82
|
+
|
83
|
+
2.7.8
|
84
|
+
==========
|
85
|
+
- Rails 5.2 compatibility (pbougie)
|
86
|
+
- Fix Session Cache compatibility (pixeltrix)
|
87
|
+
|
88
|
+
2.7.7
|
89
|
+
==========
|
90
|
+
- Support large cache keys on fetch multi (sobrinho)
|
91
|
+
- Not found checks no longer trigger the result's equality method (dannyfallon)
|
92
|
+
- Use SVG build badges (olleolleolle)
|
93
|
+
- Travis updates (junaruga, tiarly, petergoldstein)
|
94
|
+
- Update default down_retry_delay (jaredhales)
|
95
|
+
- Close kgio socket after IO.select timeouts
|
96
|
+
- Documentation updates (tipair)
|
97
|
+
- Instrument DalliStore errors with instrument_errors configuration option. (btatnall)
|
98
|
+
|
99
|
+
2.7.6
|
100
|
+
==========
|
101
|
+
- Rails 5.0.0.beta2 compatibility (yui-knk, petergoldstein)
|
102
|
+
- Add cas!, a variant of the #cas method that yields to the block whether or not the key already exist (mwpastore)
|
103
|
+
- Performance improvements (nateberkopec)
|
104
|
+
- Add Ruby 2.3.0 to support matrix (tricknotes)
|
105
|
+
|
106
|
+
2.7.5
|
107
|
+
==========
|
108
|
+
|
109
|
+
- Support rcvbuff and sndbuff byte configuration. (btatnall)
|
110
|
+
- Add `:cache_nils` option to support nil values in `DalliStore#fetch` and `Dalli::Client#fetch` (wjordan, #559)
|
111
|
+
- Log retryable server errors with 'warn' instead of 'info' (phrinx)
|
112
|
+
- Fix timeout issue with Dalli::Client#get_multi_yielder (dspeterson)
|
113
|
+
- Escape namespaces with special regexp characters (Steven Peckins)
|
114
|
+
- Ensure LocalCache supports the `:raw` option and Entry unwrapping (sj26)
|
115
|
+
- Ensure bad ttl values don't cause Dalli::RingError (eagletmt, petergoldstein)
|
116
|
+
- Always pass namespaced key to instrumentation API (kaorimatz)
|
117
|
+
- Replace use of deprecated TimeoutError with Timeout::Error (eagletmt)
|
118
|
+
- Clean up gemspec, and use Bundler for loading (grosser)
|
119
|
+
- Dry up local cache testing (grosser)
|
120
|
+
|
121
|
+
2.7.4
|
122
|
+
==========
|
123
|
+
|
124
|
+
- Restore Windows compatibility (dfens, #524)
|
125
|
+
|
126
|
+
2.7.3
|
127
|
+
==========
|
128
|
+
|
129
|
+
- Assorted spec improvements
|
130
|
+
- README changes to specify defaults for failover and compress options (keen99, #470)
|
131
|
+
- SASL authentication changes to deal with Unicode characters (flypiggy, #477)
|
132
|
+
- Call to_i on ttl to accomodate ActiveSupport::Duration (#494)
|
133
|
+
- Change to implicit blocks for performance (glaucocustodio, #495)
|
134
|
+
- Change to each_key for performance (jastix, #496)
|
135
|
+
- Support stats settings - (dterei, #500)
|
136
|
+
- Raise DallError if hostname canno be parsed (dannyfallon, #501)
|
137
|
+
- Fix instrumentation for falsey values (AlexRiedler, #514)
|
138
|
+
- Support UNIX socket configurations (r-stu31, #515)
|
139
|
+
|
140
|
+
2.7.2
|
141
|
+
==========
|
142
|
+
|
143
|
+
- The fix for #423 didn't make it into the released 2.7.1 gem somehow.
|
144
|
+
|
145
|
+
2.7.1
|
146
|
+
==========
|
147
|
+
|
148
|
+
- Rack session will check if servers are up on initialization (arthurnn, #423)
|
149
|
+
- Add support for IPv6 addresses in hex form, ie: "[::1]:11211" (dplummer, #428)
|
150
|
+
- Add symbol support for namespace (jingkai #431)
|
151
|
+
- Support expiration intervals longer than 30 days (leonid-shevtsov #436)
|
152
|
+
|
4
153
|
2.7.0
|
5
154
|
==========
|
6
155
|
|
156
|
+
- BREAKING CHANGE:
|
157
|
+
Dalli::Client#add and #replace now return a truthy value, not boolean true or false.
|
7
158
|
- Multithreading support with dalli\_store:
|
8
159
|
Use :pool\_size to create a pool of shared, threadsafe Dalli clients in Rails:
|
9
160
|
```ruby
|
data/LICENSE
CHANGED
data/README.md
CHANGED
@@ -1,42 +1,21 @@
|
|
1
|
-
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
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.
|
5
5
|
|
6
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
7
|
|
8
|
-
![Persistence of Memory](
|
8
|
+
![Persistence of Memory](https://upload.wikimedia.org/wikipedia/en/d/dd/The_Persistence_of_Memory.jpg)
|
9
9
|
|
10
10
|
Dalli's initial development was sponsored by [CouchBase](http://www.couchbase.com/). Many thanks to them!
|
11
11
|
|
12
|
-
|
13
|
-
Design
|
14
|
-
------------
|
15
|
-
|
16
|
-
I 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
12
|
Supported Ruby versions and implementations
|
33
13
|
------------------------------------------------
|
34
14
|
|
35
|
-
Dalli
|
15
|
+
As of Dalli version 3.0 the following Ruby versions are supported:
|
36
16
|
|
37
|
-
*
|
38
|
-
*
|
39
|
-
* Rubinius 2.0
|
17
|
+
* Ruby 2.5.x, 2.6.x, 2.7.x, 3.0.x
|
18
|
+
* JRuby 9.2.x, 9.3.x
|
40
19
|
|
41
20
|
If you have problems, please enter an issue.
|
42
21
|
|
@@ -44,7 +23,7 @@ If you have problems, please enter an issue.
|
|
44
23
|
Installation and Usage
|
45
24
|
------------------------
|
46
25
|
|
47
|
-
Remember, Dalli **requires** memcached 1.4+. You can check the version with `memcached -h`. Please note that memcached that Mac OS X Snow Leopard ships with is 1.2.8 and won't work. Install
|
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
|
48
27
|
|
49
28
|
brew install memcached
|
50
29
|
|
@@ -60,96 +39,65 @@ gem install dalli
|
|
60
39
|
|
61
40
|
```ruby
|
62
41
|
require 'dalli'
|
63
|
-
options = { :
|
42
|
+
options = { namespace: "app_v1", compress: true }
|
64
43
|
dc = Dalli::Client.new('localhost:11211', options)
|
65
44
|
dc.set('abc', 123)
|
66
45
|
value = dc.get('abc')
|
67
46
|
```
|
68
47
|
|
69
|
-
|
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
|
-
To use Dalli for Rails session storage that times out after 20 minutes, in `config/initializers/session_store.rb`:
|
98
|
-
|
99
|
-
For Rails >= 3.2.4:
|
100
|
-
|
101
|
-
```ruby
|
102
|
-
Rails.application.config.session_store ActionDispatch::Session::CacheStore, :expire_after => 20.minutes
|
103
|
-
```
|
104
|
-
|
105
|
-
For Rails 3.x:
|
106
|
-
|
48
|
+
With SSL enabled:
|
107
49
|
```ruby
|
108
|
-
require '
|
109
|
-
|
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")
|
110
60
|
```
|
111
61
|
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
Multithreading and Rails
|
116
|
-
--------------------------
|
117
|
-
|
118
|
-
If you use Puma or another threaded app server, as of Dalli 2.7, you can use a pool
|
119
|
-
of Dalli clients with Rails to ensure the `Rails.cache` singleton does not become a
|
120
|
-
source of thread contention. You must add `gem 'connection_pool'` to your Gemfile and
|
121
|
-
add :pool\_size to your `dalli_store` config:
|
122
|
-
|
123
|
-
```ruby
|
124
|
-
config.cache_store = :dalli_store, 'cache-1.example.com', { :pool_size => 5 }
|
125
|
-
```
|
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.
|
126
63
|
|
64
|
+
Dalli has no runtime dependencies.
|
127
65
|
|
128
66
|
Configuration
|
129
67
|
------------------------
|
130
68
|
|
69
|
+
**servers**: An Array of "host:port:weight" where weight allows you to distribute cache unevenly.
|
70
|
+
|
131
71
|
Dalli::Client accepts the following options. All times are in seconds.
|
132
72
|
|
133
73
|
**expires_in**: Global default for key TTL. Default is 0, which means no expiry.
|
134
74
|
|
135
|
-
**
|
136
|
-
|
137
|
-
**compress**: Boolean, if true Dalli will gzip-compress values larger than 1K.
|
75
|
+
**namespace**: If specified, prepends each key with this value to provide simple namespacing. Default is nil.
|
138
76
|
|
139
|
-
**
|
77
|
+
**failover**: Boolean, if true Dalli will failover to another server if the main server for a key is down. Default is true.
|
140
78
|
|
141
|
-
**
|
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.
|
142
80
|
|
143
81
|
**serializer**: The serializer to use for objects being stored (ex. JSON).
|
144
82
|
Default is Marshal.
|
145
83
|
|
146
|
-
**
|
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.
|
147
95
|
|
148
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.
|
149
97
|
|
150
|
-
**socket_failure_delay**: Before retrying a socket operation, the process sleeps for this amount of time. Default is 0.
|
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.
|
151
99
|
|
152
|
-
**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
|
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.
|
153
101
|
|
154
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.
|
155
103
|
|
@@ -157,16 +105,20 @@ Default is Marshal.
|
|
157
105
|
|
158
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.
|
159
107
|
|
160
|
-
**
|
108
|
+
**sndbuf**: In bytes, set the socket SO_SNDBUF. Defaults to operating system default.
|
161
109
|
|
162
|
-
**
|
163
|
-
|
164
|
-
If
|
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.
|
165
117
|
|
166
118
|
Features and Changes
|
167
119
|
------------------------
|
168
120
|
|
169
|
-
By default, Dalli is thread-safe.
|
121
|
+
By default, Dalli is thread-safe. Disable thread-safety at your own peril.
|
170
122
|
|
171
123
|
Dalli does not need anything special in Unicorn/Passenger since 2.0.4.
|
172
124
|
It will detect sockets shared with child processes and gracefully reopen the
|
@@ -179,27 +131,29 @@ Note that Dalli does not require ActiveSupport or Rails. You can safely use it
|
|
179
131
|
Helping Out
|
180
132
|
-------------
|
181
133
|
|
182
|
-
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.
|
134
|
+
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.
|
183
135
|
|
184
|
-
We're not accepting new compressors. They are trivial to add in an initializer. See #385 (LZ4), #406 (Snappy)
|
136
|
+
We're not accepting new compressors. They are trivial to add in an initializer. See [#385](https://github.com/petergoldstein/dalli/pull/385) (LZ4), [#406](https://github.com/petergoldstein/dalli/pull/406) (Snappy)
|
185
137
|
|
186
138
|
Thanks
|
187
139
|
------------
|
188
140
|
|
189
|
-
|
141
|
+
Mike Perham - for originally authoring the Dalli project and serving as maintainer and primary contributor
|
142
|
+
|
143
|
+
Eric Wong - for help using his [kgio](http://bogomips.org/kgio/) library.
|
190
144
|
|
191
145
|
Brian Mitchell - for his remix-stash project which was helpful when implementing and testing the binary protocol support.
|
192
146
|
|
193
147
|
[CouchBase](http://couchbase.com) - for their project sponsorship
|
194
148
|
|
195
|
-
|
196
|
-
Author
|
149
|
+
Authors
|
197
150
|
----------
|
198
151
|
|
199
|
-
|
152
|
+
* [Peter M. Goldstein](https://github.com/petergoldstein) - current maintainer
|
153
|
+
* [Mike Perham](https://github.com/mperham) and contributors
|
200
154
|
|
201
155
|
|
202
156
|
Copyright
|
203
157
|
-----------
|
204
158
|
|
205
|
-
Copyright (c) Mike Perham. See LICENSE for details.
|
159
|
+
Copyright (c) Mike Perham, Peter M. Goldstein. See LICENSE for details.
|
data/lib/dalli/cas/client.rb
CHANGED
@@ -1,58 +1 @@
|
|
1
|
-
require 'dalli/client'
|
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 false 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 false 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 false otherwise.
|
53
|
-
def delete_cas(key, cas=0)
|
54
|
-
perform(:delete, key, cas)
|
55
|
-
end
|
56
|
-
|
57
|
-
end
|
58
|
-
end
|
1
|
+
puts "You can remove `require 'dalli/cas/client'` as this code has been rolled into the standard 'dalli/client'."
|