dalli 2.7.11 → 3.0.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4bc4fe873fe9319c9297219b7908d576470551d0e011d1299e54ebc162256a68
4
- data.tar.gz: b60393783d05152ad67aa12298f6867127f973fbf07cd2d0dc90ab96b1d7971f
3
+ metadata.gz: 48a2e02ec2d89d9304b68d36ed3827f4677398043a875f10c78a47f0517f579b
4
+ data.tar.gz: f2f365d5bc6d353fed61fd72866460c2e2929de9097018639f78687d96dae320
5
5
  SHA512:
6
- metadata.gz: 1348b528243f253c111ad74e17a0ba20d8d14eb29d4f41e15f60bb2c87505c6d09404217c868f1623bd68f1ad70a644efd09fd1acca0ba2a1d0b6395387967ae
7
- data.tar.gz: 108c5477c6399ef838a8df14e4878509ec5f7c22c33d012c19a9deb635901e9251a52c392c080fd6eb65dfb54e8084ee70cf6668a6914fd1336120aabb19b4f9
6
+ metadata.gz: 732930e9654c116fbf3769bac8091126f831eb22d795ed8f7d70479ab3a15591576b9e88d150fc5a79590dbec309249d144de909698c010284bbb30b585c5180
7
+ data.tar.gz: 54aa18fc3808423e74507f1a3934afbbc60b78c080fc3e5bf790a1daf7832af9a8481f77c5dc8fcb428ca9743ec3f5eb3cb0258517d7cb126e5dd3c749e8f56f
data/Gemfile CHANGED
@@ -1,15 +1,10 @@
1
- source 'https://rubygems.org'
1
+ source "https://rubygems.org"
2
2
 
3
3
  gemspec
4
4
 
5
- gem 'appraisal'
6
- gem 'kgio', :platform => :mri
7
- gem 'rails'
8
-
9
5
  group :test do
10
- gem 'minitest'
11
- gem 'mocha'
12
- gem 'rake'
13
- gem 'connection_pool'
14
- gem 'simplecov'
6
+ gem "minitest"
7
+ gem "rake"
8
+ gem "simplecov"
9
+ gem "ruby-prof", platform: :mri
15
10
  end
data/History.md CHANGED
@@ -1,6 +1,34 @@
1
1
  Dalli Changelog
2
2
  =====================
3
3
 
4
+ 3.0.0
5
+ ==========
6
+ - BREAKING CHANGES:
7
+
8
+ - Removes :dalli_store.
9
+ Use Rails' official :mem_cache_store instead.
10
+ https://guides.rubyonrails.org/caching_with_rails.html
11
+ - Attempting to store a larger value than allowed by memcached used to
12
+ print a warning and truncate the value. This now raises an error to
13
+ prevent silent data corruption.
14
+ - Compression now defaults to `true` for large values (greater than 4KB).
15
+ This is intended to minimize errors due to the previous note.
16
+ - Errors marshalling values now raise rather than just printing an error.
17
+ - The Rack session adapter has been refactored to remove support for thread-unsafe
18
+ configurations. You will need to include the `connection_pool` gem in
19
+ your Gemfile to ensure session operations are thread-safe.
20
+
21
+ - Raise NetworkError when multi response gets into corrupt state (mervync, #783)
22
+ - Validate servers argument (semaperepelitsa, petergoldstein, #776)
23
+ - Enable SSL support (bdunne, #775)
24
+ - Add gat operation (tbeauvais, #769)
25
+ - Removes inline native code, use Ruby 2.3+ support for bsearch instead. (mperham)
26
+ - Switch repo to Github Actions and upgrade Ruby versions (petergoldstein, bdunne, Fryguy)
27
+ - Update benchmark test for Rubyprof changes (nateberkopec)
28
+ - Remove support for the `kgio` gem, it is not relevant in Ruby 2.3+. (mperham)
29
+ - Remove inline native code, use Ruby 2.3+ support for bsearch instead. (mperham)
30
+
31
+
4
32
  2.7.11
5
33
  ==========
6
34
  - DEPRECATION: :dalli_store will be removed in Dalli 3.0.
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- Dalli [![Build Status](https://secure.travis-ci.org/petergoldstein/dalli.svg)](http://travis-ci.org/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
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.
@@ -46,83 +46,23 @@ dc.set('abc', 123)
46
46
  value = dc.get('abc')
47
47
  ```
48
48
 
49
- 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.
50
-
51
- Dalli has no runtime dependencies.
52
-
53
- Usage with Rails 3.x and 4.x
54
- ---------------------------
55
-
56
- In your Gemfile:
57
-
49
+ With SSL enabled:
58
50
  ```ruby
59
- gem 'dalli'
60
- ```
61
-
62
- In `config/environments/production.rb`:
63
-
64
- ```ruby
65
- config.cache_store = :dalli_store
66
- ```
67
-
68
- 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.
69
-
70
- ```ruby
71
- config.cache_store = :dalli_store, 'cache-1.example.com', 'cache-2.example.com:11211:2',
72
- { :namespace => NAME_OF_RAILS_APP, :expires_in => 1.day, :compress => true }
73
- ```
74
-
75
- 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` )
76
-
77
- 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:
78
-
79
- ```ruby
80
- config.cache_store = :dalli_store, nil, { :namespace => NAME_OF_RAILS_APP, :expires_in => 1.day, :compress => true }
81
- ```
82
-
83
- To use Dalli for Rails session storage that times out after 20 minutes, in `config/initializers/session_store.rb`:
84
-
85
- For Rails >= 3.2.4:
86
-
87
- ```ruby
88
- Rails.application.config.session_store ActionDispatch::Session::CacheStore, :expire_after => 20.minutes
89
- ```
90
-
91
- For Rails 3.x:
92
-
93
- ```ruby
94
- require 'action_dispatch/middleware/session/dalli_store'
95
- Rails.application.config.session_store :dalli_store, :memcache_server => ['host1', 'host2'], :namespace => 'sessions', :key => '_foundation_session', :expire_after => 20.minutes
96
- ```
97
-
98
- Dalli does not support Rails 2.x.
99
-
100
-
101
- Multithreading and Rails
102
- --------------------------
103
-
104
- If you use Puma or another threaded app server, as of Dalli 2.7, you can use a pool
105
- of Dalli clients with Rails to ensure the `Rails.cache` singleton does not become a
106
- source of thread contention. You must add `gem 'connection_pool'` to your Gemfile and
107
- add :pool\_size to your `dalli_store` config:
108
-
109
- ```ruby
110
- config.cache_store = :dalli_store, 'cache-1.example.com', { :pool_size => 5 }
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")
111
61
  ```
112
62
 
113
- 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:
114
-
115
- ```ruby
116
- Rails.cache.fetch('foo', :expires_in => 300) do
117
- 'bar'
118
- end
119
-
120
- Rails.cache.dalli.with do |client|
121
- # client is a Dalli::Client instance which you can
122
- # use ONLY within this block
123
- end
124
- ```
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.
125
64
 
65
+ Dalli has no runtime dependencies.
126
66
 
127
67
  Configuration
128
68
  ------------------------
@@ -154,13 +94,13 @@ If serving compressed data using nginx's HttpMemcachedModule, set `memcached_gzi
154
94
 
155
95
  **keepalive**: Boolean. If true, Dalli will enable keep-alive for socket connections. Default is true.
156
96
 
157
- **socket_timeout**: Timeout for all socket operations (connect, read, write). Default is 0.5.
97
+ **socket_timeout**: Timeout for all socket operations (connect, read, write). Default is 1.
158
98
 
159
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.
160
100
 
161
- **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.
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.
162
102
 
163
- **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.
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.
164
104
 
165
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.
166
106
 
@@ -1,59 +1 @@
1
- # frozen_string_literal: true
2
- require 'dalli/client'
3
-
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
1
+ puts "You can remove `require 'dalli/cas/client'` as this code has been rolled into the standard 'dalli/client'.