-
Notifications
You must be signed in to change notification settings - Fork 235
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4098 from zendesk/grosser/mem
fix memcached on ruby 3
- Loading branch information
Showing
2 changed files
with
18 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# frozen_string_literal: true | ||
# | ||
# TODO: remove one `rails runner 'Rails.cache.fetch 1'` works with memcached | ||
# dalli has this code inside an `if RUBY_VERSION >= '3.0'` but only old version works | ||
require 'dalli' | ||
|
||
class Dalli::Socket::TCP | ||
def self.open(host, port, options = {}) | ||
Timeout.timeout(options[:socket_timeout]) do | ||
sock = new(host, port) | ||
sock.options = {host: host, port: port}.merge(options) | ||
init_socket_options(sock, options) | ||
|
||
options[:ssl_context] ? wrapping_ssl_socket(sock, host, options[:ssl_context]) : sock | ||
end | ||
end | ||
end |