diff -Nru ruby-redis-rack-2.0.2/bin/appraisal ruby-redis-rack-2.1.2/bin/appraisal --- ruby-redis-rack-2.0.2/bin/appraisal 1970-01-01 00:00:00.000000000 +0000 +++ ruby-redis-rack-2.1.2/bin/appraisal 2020-03-13 18:40:42.000000000 +0000 @@ -0,0 +1,17 @@ +#!/usr/bin/env ruby +# frozen_string_literal: true +# +# This file was generated by Bundler. +# +# The application 'appraisal' is installed as part of a gem, and +# this file is here to facilitate running it. +# + +require "pathname" +ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile", + Pathname.new(__FILE__).realpath) + +require "rubygems" +require "bundler/setup" + +load Gem.bin_path("appraisal", "appraisal") diff -Nru ruby-redis-rack-2.0.2/bin/rake ruby-redis-rack-2.1.2/bin/rake --- ruby-redis-rack-2.0.2/bin/rake 1970-01-01 00:00:00.000000000 +0000 +++ ruby-redis-rack-2.1.2/bin/rake 2020-03-13 18:40:42.000000000 +0000 @@ -0,0 +1,17 @@ +#!/usr/bin/env ruby +# frozen_string_literal: true +# +# This file was generated by Bundler. +# +# The application 'rake' is installed as part of a gem, and +# this file is here to facilitate running it. +# + +require "pathname" +ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile", + Pathname.new(__FILE__).realpath) + +require "rubygems" +require "bundler/setup" + +load Gem.bin_path("rake", "rake") diff -Nru ruby-redis-rack-2.0.2/CHANGELOG.md ruby-redis-rack-2.1.2/CHANGELOG.md --- ruby-redis-rack-2.0.2/CHANGELOG.md 1970-01-01 00:00:00.000000000 +0000 +++ ruby-redis-rack-2.1.2/CHANGELOG.md 2020-03-13 18:40:42.000000000 +0000 @@ -0,0 +1,246 @@ +v2.1.0 (2020-01-13) +-------------------------------------------------------------------------------- + +* Update version to v2.1.0 final + Tom Scott + +* Test against most recent versions of Ruby + Tom Scott + +* Update gemspec to remove rubyforge_project + + It is deprecated or removed already + + Original warning message: + Gem::Specification#rubyforge_project= is deprecated with no replacement. It will be removed on or after 2019-12-01. + PikachuEXE + +* back tests to original state + Alexey Vasiliev + +* Fix redis-rack for rack 2.0.8, small improvements + Alexey Vasiliev + +* Fix redis-rack for rack 2.0.8, fix generate_unique_sid + Alexey Vasiliev + +* Fix redis-rack for rack 2.0.8 + Alexey Vasiliev + +* v2.1.0.pre: Update Rack Session API, drop support for Rack 1.0 + Tom Scott + +v2.0.6 +-------------------------------------------------------------------------------- + +* v2.0.6: Prevent Connection Pool from passing nil options + Tom Scott + +* Make bundler dependency more permissive to support future ruby versions + Tom Scott + +* Drop support for Rack v1 + Tom Scott + +* Update Rack::Session API Compatibility + + The latest version of Rack [deprecated subclassing Rack::Session::ID](https://github.com/rack/rack/blob/master/lib/rack/session/abstract/id.rb#L412-L419), + replacing it instead with `Rack::Session::Persisted`. Update the method + implementations in this gem to support the new API. Shoutouts to @onk + for actually writing this code, we're pulling it in from his fork. + Tom Scott + +* Automatically assign issues to @tubbo when they are created + Tom Scott + +* Automatically release to RubyGems when new tags are pushed to GitHub + Tom Scott + +* Raise Error when `:redis_store` is Incorrect Type + + Passing an object that isn't a `Redis::Store` into the session storage + configuration can cause errors when methods are called with more + arguments than the default Redis client can handle. These additional + arguments are used by `Rack::Session::Redis` to configure the key + namespace and TTL globally in the main configuration, and pass them down + to `Redis::Store` to be appended to the key. An `ArgumentError` will now + be thrown when a `:redis_store` is of a type that isn't a `Redis::Store` + (or a subclass thereof). + + Resolves #46 + Tom Scott + +* Add code owners + Tom Scott + +* Do not provide nil values for missing connection pool options + + Fixes #44 + Jake Goulding + +v2.0.5 +-------------------------------------------------------------------------------- + +* v2.0.5 release + Tom Scott + +* add spec to validate blank sessions are not stored in redis + mstruve + +* dont store a blank session in redis + mstruve + +* Add documentation for options + Daniel M Barlow + +v2.0.4 +-------------------------------------------------------------------------------- + +* Release 2.0.4 + Tom Scott + +* Remove .ruby-version + Tom Scott + +* Remove rake, appraisal from gemspec executables + + The contents of the bin directory are binstubs to assist development. + They are not intended to be shipped with the gem itself. This commit + updates the gemspec to ensure that they are not exposed to rubygems as + executables for redis-rack, which will fix conflicts with the legitimate + rake and appraisal executables provided by those other gems. + Matt Brictson + +v2.0.3 +-------------------------------------------------------------------------------- + +* v2.0.3: Avoid mutex locking with global option + Tom Scott + +* Restore default_options in #generate_unique_sid + Tom Scott + +* Refactor connection_pool code + + Adds a `Redis::Rack::Connection` object for handling the instantiation + of a `Redis::Store` or a `ConnectionPool` if pool configuration is + given. Restores the purpose of `Rack::Session::Redis` to only implement + the session ID abstract API provided by Rack. + Tom Scott + +* Rename :use_global_lock option to :threadsafe to match Rails + Garrett Thornburg + +* Use mocha mocks to assert the mutex is never locked + Garrett Thornburg + +* Allow redis-store v1.4 + Shane O'Grady + +* Create a :use_global_lock option that avoids the global lock + Garrett Thornburg + +* Rake task for running all tests on all gem versions + Tom Scott + +* Install Appraisal so we can test against multiple versions of Rack + Tom Scott + +v2.0.2 +-------------------------------------------------------------------------------- + +* v2.0.2: Resolve regression forcing Rack 2.x and above + Tom Scott + +v2.0.1 +-------------------------------------------------------------------------------- + +* v2.0.1: Relax gem dependencies + Tom Scott + +* smoothen redis-store dependency + Mathieu Jobin + +* Drop support for Rubinius 1.9 mode + + 1.9.x is EOL in MRI Ruby Land, and Rubinius 1.9 mode isn't really used + much anymore. This should make the builds pass again. + Tom Scott + +* Update README.md (#20) + Nicolas + +* Remove jruby 1.9 mode from the build matrix + Tom Scott + +* Remove test because why + Tom Scott + +v2.0.0 +-------------------------------------------------------------------------------- + +* v2.0: Drop support for Ruby below 2.2 (thanks @connorshea) + + Fixes #17, major shoutouts to @connorshea for getting this off the + ground. This also edits the CI config to drop support for older Ruby + versions. + Tom Scott + +* Fix gem dependency versions + Tom Scott + +* v2.0.0.pre Add support for Rails 5 and Rack 2. + Tom Scott + +* v2.0.0: Upgrade to Rack 2.0 + + This release includes some backwards-incompatible changes that pertain + to Rails' upgrade to Rack 2.x. + Tom Scott + +* Update README + Tom Scott + +* Fix readme + Tom Scott + +* travis.yml add Ruby 2.3.0 + shiro16 + +* add 2.1 and 2.2 rubies to travis + Marc Roberts + +* Remove support for Ruby 1.9 + Marc Roberts + +* Loosen dependancy on Rack to allow 1.5 and 2.x + + Rails 5 beta requires Rack 2.x and this gem is unusable unless can use Rack 2.x + Marc Roberts + +* Update README.md + Ryan Bigg + +* add support for ConnectionPool + Roman Usherenko + +* Introduce redis_store option (closes #1) + Kurakin Alexander + +* Atomically lock session id and implement skip support. + W. Andrew Loe III + +v1.5.0 +------ + +* Enable CI + Luca Guidi + +* Update README.md + Luca Guidi + +* Moved back from jodosha/redis-store + Luca Guidi + +* Moved + Luca Guidi diff -Nru ruby-redis-rack-2.0.2/CODEOWNERS ruby-redis-rack-2.1.2/CODEOWNERS --- ruby-redis-rack-2.0.2/CODEOWNERS 1970-01-01 00:00:00.000000000 +0000 +++ ruby-redis-rack-2.1.2/CODEOWNERS 2020-03-13 18:40:42.000000000 +0000 @@ -0,0 +1 @@ +* @tubbo diff -Nru ruby-redis-rack-2.0.2/debian/changelog ruby-redis-rack-2.1.2/debian/changelog --- ruby-redis-rack-2.0.2/debian/changelog 2018-02-23 07:57:03.000000000 +0000 +++ ruby-redis-rack-2.1.2/debian/changelog 2020-04-10 05:07:21.000000000 +0000 @@ -1,3 +1,50 @@ +ruby-redis-rack (2.1.2-4) unstable; urgency=medium + + * Team upload + * Reupload to unstable + * Tighten dependency on ruby-rack (2.1 now available in unstable) + + -- Pirate Praveen Fri, 10 Apr 2020 10:37:21 +0530 + +ruby-redis-rack (2.1.2-3) experimental; urgency=medium + + * Relax dependency on ruby-rack + + -- Pirate Praveen Tue, 17 Mar 2020 21:50:46 +0530 + +ruby-redis-rack (2.1.2-2) experimental; urgency=medium + + * Team upload + * Use --gem-install option (to skip installing bin as /usr/bin) + + -- Pirate Praveen Sat, 14 Mar 2020 00:34:48 +0530 + +ruby-redis-rack (2.1.2-1) experimental; urgency=medium + + * Team upload + + [ Utkarsh Gupta ] + * Add salsa-ci.yml + + [ Debian Janitor ] + * Trim trailing whitespace. + * Use secure copyright file specification URI. + * Use secure URI in debian/watch. + * Bump debhelper from old 11 to 12. + * Set debhelper-compat version in Build-Depends. + * Set upstream metadata fields: Bug-Database, Bug-Submit, Repository, + Repository-Browse. + * Update Vcs-* headers from URL redirect. + * Use canonical URL in Vcs-Git. + + [ Pirate Praveen ] + * New upstream version 2.1.2 + * Move debian/watch to gemwatch.debian.net + * Bump Standards-Version to 4.5.0 (no changes needed) + * Use ruby-rack 2.1 for tests + + -- Pirate Praveen Sat, 14 Mar 2020 00:11:42 +0530 + ruby-redis-rack (2.0.2-2) unstable; urgency=medium * Team upload @@ -17,19 +64,19 @@ ruby-redis-rack (1.5.0-7) unstable; urgency=medium - * Fix homepage field in debian/control + * Fix homepage field in debian/control -- Balasankar C Sat, 18 Jul 2015 10:13:43 +0530 ruby-redis-rack (1.5.0-6) unstable; urgency=medium - * Add minitest to build dependency + * Add minitest to build dependency -- Balasankar C Mon, 22 Jun 2015 17:59:50 +0530 ruby-redis-rack (1.5.0-5) unstable; urgency=medium - * Reupload to unstable + * Reupload to unstable -- Balasankar C Thu, 29 Jan 2015 18:06:41 +0530 @@ -43,14 +90,14 @@ ruby-redis-rack (1.5.0-3) experimental; urgency=medium * Debian update - * Move start and stop of redis-server to rake + * Move start and stop of redis-server to rake -- Balasankar C Tue, 02 Dec 2014 20:17:58 +0530 ruby-redis-rack (1.5.0-2) experimental; urgency=medium * Debian update - * Remove dependency of version in lib folder + * Remove dependency of version in lib folder -- Balasankar C Tue, 02 Dec 2014 00:16:37 +0530 diff -Nru ruby-redis-rack-2.0.2/debian/compat ruby-redis-rack-2.1.2/debian/compat --- ruby-redis-rack-2.0.2/debian/compat 2018-02-23 07:57:03.000000000 +0000 +++ ruby-redis-rack-2.1.2/debian/compat 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -11 diff -Nru ruby-redis-rack-2.0.2/debian/control ruby-redis-rack-2.1.2/debian/control --- ruby-redis-rack-2.0.2/debian/control 2018-02-23 07:57:03.000000000 +0000 +++ ruby-redis-rack-2.1.2/debian/control 2020-04-10 05:07:21.000000000 +0000 @@ -3,17 +3,17 @@ Priority: optional Maintainer: Debian Ruby Extras Maintainers Uploaders: Balasankar C -Build-Depends: debhelper (>= 11~), +Build-Depends: debhelper-compat (= 12), gem2deb, procps, ruby-minitest, ruby-mocha, - ruby-rack, + ruby-rack (>= 2.1~), ruby-redis-store (>= 1.2~), ruby-connection-pool -Standards-Version: 4.1.3 -Vcs-Git: https://anonscm.debian.org/git/pkg-ruby-extras/ruby-redis-rack.git -Vcs-Browser: https://anonscm.debian.org/cgit/pkg-ruby-extras/ruby-redis-rack.git +Standards-Version: 4.5.0 +Vcs-Git: https://salsa.debian.org/ruby-team/ruby-redis-rack.git +Vcs-Browser: https://salsa.debian.org/ruby-team/ruby-redis-rack Homepage: https://github.com/redis-store/redis-rack Testsuite: autopkgtest-pkg-ruby XS-Ruby-Versions: all @@ -22,7 +22,7 @@ Architecture: all XB-Ruby-Versions: ${ruby:Versions} Depends: ruby | ruby-interpreter, - ruby-rack, + ruby-rack (>= 2.1~), ruby-redis-store (>= 1.2~), ${misc:Depends}, ${shlibs:Depends} diff -Nru ruby-redis-rack-2.0.2/debian/copyright ruby-redis-rack-2.1.2/debian/copyright --- ruby-redis-rack-2.0.2/debian/copyright 2018-02-23 07:57:03.000000000 +0000 +++ ruby-redis-rack-2.1.2/debian/copyright 2020-04-10 05:07:21.000000000 +0000 @@ -1,4 +1,4 @@ -Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ +Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ Upstream-Name: redis-rack Source: https://github.com/redis-store/redis-rack diff -Nru ruby-redis-rack-2.0.2/debian/patches/version ruby-redis-rack-2.1.2/debian/patches/version --- ruby-redis-rack-2.0.2/debian/patches/version 2018-02-23 07:57:03.000000000 +0000 +++ ruby-redis-rack-2.1.2/debian/patches/version 1970-01-01 00:00:00.000000000 +0000 @@ -1,27 +0,0 @@ -Description: requiring version from lib - Require version.rb from lib folder. - . - ruby-redis-rack (1.5.0-1) unstable; urgency=medium - . - * Initial release (Closes: #771401) -Author: Balasankar C -Bug-Debian: https://bugs.debian.org/771401 - - ---- ruby-redis-rack-1.5.0.orig/test/redis/rack/version_test.rb -+++ ruby-redis-rack-1.5.0/test/redis/rack/version_test.rb -@@ -1,5 +1,5 @@ - require 'test_helper' -- -+require 'redis/rack/version' - describe Redis::Rack::VERSION do - it 'returns current version' do - Redis::Rack::VERSION.must_equal '1.5.0' ---- ruby-redis-rack-1.5.0.orig/test/test_helper.rb -+++ ruby-redis-rack-1.5.0/test/test_helper.rb -@@ -1,4 +1,4 @@ --require 'bundler/setup' -+#require 'bundler/setup' - require 'minitest/autorun' - require 'mocha/setup' - require 'rack' diff -Nru ruby-redis-rack-2.0.2/debian/rules ruby-redis-rack-2.1.2/debian/rules --- ruby-redis-rack-2.0.2/debian/rules 2018-02-23 07:57:03.000000000 +0000 +++ ruby-redis-rack-2.1.2/debian/rules 2020-04-10 05:07:21.000000000 +0000 @@ -1,15 +1,6 @@ #!/usr/bin/make -f -#export DH_VERBOSE=1 -# -# Uncomment to ignore all test failures (but the tests will run anyway) -#export DH_RUBY_IGNORE_TESTS=all -# -# Uncomment to ignore some test failures (but the tests will run anyway). -# Valid values: -#export DH_RUBY_IGNORE_TESTS=ruby2.1 require-rubygems -# -# If you need to specify the .gemspec (eg there is more than one) -#export DH_RUBY_GEMSPEC=gem.gemspec + +export DH_RUBY = --gem-install %: dh $@ --buildsystem=ruby --with ruby diff -Nru ruby-redis-rack-2.0.2/debian/salsa-ci.yml ruby-redis-rack-2.1.2/debian/salsa-ci.yml --- ruby-redis-rack-2.0.2/debian/salsa-ci.yml 1970-01-01 00:00:00.000000000 +0000 +++ ruby-redis-rack-2.1.2/debian/salsa-ci.yml 2020-04-10 05:07:21.000000000 +0000 @@ -0,0 +1,4 @@ +--- +include: + - https://salsa.debian.org/salsa-ci-team/pipeline/raw/master/salsa-ci.yml + - https://salsa.debian.org/salsa-ci-team/pipeline/raw/master/pipeline-jobs.yml diff -Nru ruby-redis-rack-2.0.2/debian/upstream/metadata ruby-redis-rack-2.1.2/debian/upstream/metadata --- ruby-redis-rack-2.0.2/debian/upstream/metadata 1970-01-01 00:00:00.000000000 +0000 +++ ruby-redis-rack-2.1.2/debian/upstream/metadata 2020-04-10 05:07:21.000000000 +0000 @@ -0,0 +1,4 @@ +Bug-Database: https://github.com/redis-store/redis-rack/issues +Bug-Submit: https://github.com/redis-store/redis-rack/issues/new +Repository: https://github.com/redis-store/redis-rack.git +Repository-Browse: https://github.com/redis-store/redis-rack diff -Nru ruby-redis-rack-2.0.2/debian/watch ruby-redis-rack-2.1.2/debian/watch --- ruby-redis-rack-2.0.2/debian/watch 2018-02-23 07:57:03.000000000 +0000 +++ ruby-redis-rack-2.1.2/debian/watch 2020-04-10 05:07:21.000000000 +0000 @@ -1,2 +1,2 @@ version=3 -http://pkg-ruby-extras.alioth.debian.org/cgi-bin/gemwatch/redis-rack .*/redis-rack-(.*).tar.gz +https://gemwatch.debian.net/redis-rack .*/redis-rack-(.*).tar.gz diff -Nru ruby-redis-rack-2.0.2/Gemfile ruby-redis-rack-2.1.2/Gemfile --- ruby-redis-rack-2.0.2/Gemfile 2017-04-26 08:49:57.000000000 +0000 +++ ruby-redis-rack-2.1.2/Gemfile 2020-03-13 18:40:42.000000000 +0000 @@ -1,2 +1,5 @@ source 'https://rubygems.org' gemspec +gem 'redis-store-testing', github: 'redis-store/testing' + +gem "appraisal", "~> 2.2" diff -Nru ruby-redis-rack-2.0.2/.github/auto-assign-issues.yml ruby-redis-rack-2.1.2/.github/auto-assign-issues.yml --- ruby-redis-rack-2.0.2/.github/auto-assign-issues.yml 1970-01-01 00:00:00.000000000 +0000 +++ ruby-redis-rack-2.1.2/.github/auto-assign-issues.yml 2020-03-13 18:40:42.000000000 +0000 @@ -0,0 +1,2 @@ +assignees: + - tubbo diff -Nru ruby-redis-rack-2.0.2/.gitignore ruby-redis-rack-2.1.2/.gitignore --- ruby-redis-rack-2.0.2/.gitignore 2017-04-26 08:49:57.000000000 +0000 +++ ruby-redis-rack-2.1.2/.gitignore 2020-03-13 18:40:42.000000000 +0000 @@ -2,3 +2,5 @@ *.gem tmp/ stdout +gemfiles/vendor +gemfiles/*.gemfile.lock diff -Nru ruby-redis-rack-2.0.2/lib/rack/session/redis.rb ruby-redis-rack-2.1.2/lib/rack/session/redis.rb --- ruby-redis-rack-2.0.2/lib/rack/session/redis.rb 2017-04-26 08:49:57.000000000 +0000 +++ ruby-redis-rack-2.1.2/lib/rack/session/redis.rb 2020-03-13 18:40:42.000000000 +0000 @@ -1,53 +1,41 @@ require 'rack/session/abstract/id' require 'redis-store' require 'thread' +require 'redis/rack/connection' module Rack module Session - class Redis < Abstract::ID - attr_reader :mutex, :pool + class Redis < Abstract::PersistedSecure + attr_reader :mutex - DEFAULT_OPTIONS = Abstract::ID::DEFAULT_OPTIONS.merge \ + DEFAULT_OPTIONS = Abstract::ID::DEFAULT_OPTIONS.merge( :redis_server => 'redis://127.0.0.1:6379/0/rack:session' + ) def initialize(app, options = {}) super @mutex = Mutex.new - @pool = if @default_options[:pool] - raise "pool must be an instance of ConnectionPool" unless @default_options[:pool].is_a?(ConnectionPool) - @pooled = true - @default_options[:pool] - elsif [:pool_size, :pool_timeout].any? { |key| @default_options.has_key?(key) } - pool_options = {} - pool_options[:size] = options[:pool_size] if options[:pool_size] - pool_options[:timeout] = options[:pool_timeout] if options[:pool_timeout] - @pooled = true - ::ConnectionPool.new(pool_options) { ::Redis::Store::Factory.create(@default_options[:redis_server]) } - else - @default_options.has_key?(:redis_store) ? - @default_options[:redis_store] : - ::Redis::Store::Factory.create(@default_options[:redis_server]) - - end + @conn = ::Redis::Rack::Connection.new(@default_options) end def generate_unique_sid(session) + return generate_sid if session.empty? loop do sid = generate_sid first = with do |c| - [*c.setnx(sid, session, @default_options)].first + [*c.setnx(sid.private_id, session, @default_options)].first end break sid if [1, true].include?(first) end end - def get_session(env, sid) - if env['rack.session.options'][:skip] + def find_session(req, sid) + if req.session.options[:skip] [generate_sid, {}] else - with_lock(env, [nil, {}]) do - unless sid and session = with { |c| c.get(sid) } + with_lock(req, [nil, {}]) do + unless sid and session = get_session_with_fallback(sid) session = {} sid = generate_unique_sid(session) end @@ -56,22 +44,29 @@ end end - def set_session(env, session_id, new_session, options) - with_lock(env, false) do - with { |c| c.set session_id, new_session, options } - session_id + def write_session(req, sid, new_session, options) + with_lock(req, false) do + with { |c| c.set sid.private_id, new_session, options } + sid end end - def destroy_session(env, session_id, options) - with_lock(env) do - with { |c| c.del(session_id) } + def delete_session(req, sid, options) + with_lock(req) do + with do |c| + c.del(sid.public_id) + c.del(sid.private_id) + end generate_sid unless options[:drop] end end - def with_lock(env, default=nil) - @mutex.lock if env['rack.multithread'] + def threadsafe? + @default_options.fetch(:threadsafe, true) + end + + def with_lock(req, default=nil) + @mutex.lock if req.multithread? && threadsafe? yield rescue Errno::ECONNREFUSED if $VERBOSE @@ -84,14 +79,14 @@ end def with(&block) - if @pooled - @pool.with(&block) - else - block.call(@pool) - end + @conn.with(&block) end + private + + def get_session_with_fallback(sid) + with { |c| c.get(sid.private_id) || c.get(sid.public_id) } + end end end end - diff -Nru ruby-redis-rack-2.0.2/lib/redis/rack/connection.rb ruby-redis-rack-2.1.2/lib/redis/rack/connection.rb --- ruby-redis-rack-2.0.2/lib/redis/rack/connection.rb 1970-01-01 00:00:00.000000000 +0000 +++ ruby-redis-rack-2.1.2/lib/redis/rack/connection.rb 2020-03-13 18:40:42.000000000 +0000 @@ -0,0 +1,46 @@ +class Redis + module Rack + class Connection + def initialize(options = {}) + @options = options + @store = options[:redis_store] + @pool = options[:pool] + + if @pool && !@pool.is_a?(ConnectionPool) + raise ArgumentError, "pool must be an instance of ConnectionPool" + end + + if @store && !@store.is_a?(Redis::Store) + raise ArgumentError, "redis_store must be an instance of Redis::Store (currently #{@store.class.name})" + end + end + + def with(&block) + if pooled? + pool.with(&block) + else + block.call(store) + end + end + + def pooled? + [:pool, :pool_size, :pool_timeout].any? { |key| @options.key?(key) } + end + + def pool + @pool ||= ConnectionPool.new(pool_options) { store } if pooled? + end + + def store + @store ||= Redis::Store::Factory.create(@options[:redis_server]) + end + + def pool_options + { + size: @options[:pool_size], + timeout: @options[:pool_timeout] + }.reject { |key, value| value.nil? }.to_h + end + end + end +end diff -Nru ruby-redis-rack-2.0.2/lib/redis/rack/version.rb ruby-redis-rack-2.1.2/lib/redis/rack/version.rb --- ruby-redis-rack-2.0.2/lib/redis/rack/version.rb 2017-04-26 08:49:57.000000000 +0000 +++ ruby-redis-rack-2.1.2/lib/redis/rack/version.rb 2020-03-13 18:40:42.000000000 +0000 @@ -1,6 +1,5 @@ class Redis module Rack - VERSION = '2.0.2' + VERSION = '2.1.2' end end - diff -Nru ruby-redis-rack-2.0.2/Rakefile ruby-redis-rack-2.1.2/Rakefile --- ruby-redis-rack-2.0.2/Rakefile 2017-04-26 08:49:57.000000000 +0000 +++ ruby-redis-rack-2.1.2/Rakefile 2020-03-13 18:40:42.000000000 +0000 @@ -2,3 +2,9 @@ require 'rake' require 'bundler/gem_tasks' require 'redis-store/testing/tasks' + +task :all do + Dir["gemfiles/*.gemfile"].reject { |p| p =~ /\.lock\Z/ }.each do |gemfile| + sh "BUNDLE_GEMFILE=#{gemfile} bundle exec rake" + end +end diff -Nru ruby-redis-rack-2.0.2/README.md ruby-redis-rack-2.1.2/README.md --- ruby-redis-rack-2.0.2/README.md 2017-04-26 08:49:57.000000000 +0000 +++ ruby-redis-rack-2.1.2/README.md 2020-03-13 18:40:42.000000000 +0000 @@ -42,6 +42,11 @@ require 'rack/session/redis' use Rack::Session::Redis + +# Alternatively you can specify options to use: +use Rack::Session::Redis, + :redis_server => "redis://redis:6379/0", + :expires_in => 3600 # Seconds. If you are using ActiveSupport you can use 1.hour ``` ## Development diff -Nru ruby-redis-rack-2.0.2/redis-rack.gemspec ruby-redis-rack-2.1.2/redis-rack.gemspec --- ruby-redis-rack-2.0.2/redis-rack.gemspec 2017-04-26 08:49:57.000000000 +0000 +++ ruby-redis-rack-2.1.2/redis-rack.gemspec 2020-03-13 18:40:42.000000000 +0000 @@ -12,21 +12,18 @@ s.description = %q{Redis Store for Rack applications} s.license = 'MIT' - s.rubyforge_project = 'redis-rack' - s.files = `git ls-files`.split("\n") s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n") - s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) } + s.executables = [] s.require_paths = ["lib"] - s.add_runtime_dependency 'redis-store', ['< 1.4', '>= 1.2'] - s.add_runtime_dependency 'rack', '>= 1.5', '< 3' + s.add_runtime_dependency 'redis-store', ['< 2', '>= 1.2'] + s.add_runtime_dependency 'rack', '>= 2.0.8', '< 3' s.add_development_dependency 'rake', '~> 10' - s.add_development_dependency 'bundler', '~> 1.3' + s.add_development_dependency 'bundler', '> 1', '< 3' s.add_development_dependency 'mocha', '~> 0.14.0' s.add_development_dependency 'minitest', '~> 5' - s.add_development_dependency 'redis-store-testing' s.add_development_dependency 'connection_pool', '~> 1.2.0' end diff -Nru ruby-redis-rack-2.0.2/.ruby-version ruby-redis-rack-2.1.2/.ruby-version --- ruby-redis-rack-2.0.2/.ruby-version 2017-04-26 08:49:57.000000000 +0000 +++ ruby-redis-rack-2.1.2/.ruby-version 2020-03-13 18:40:42.000000000 +0000 @@ -1 +1 @@ -2.2.2 +2.6.2 diff -Nru ruby-redis-rack-2.0.2/test/rack/session/redis_test.rb ruby-redis-rack-2.1.2/test/rack/session/redis_test.rb --- ruby-redis-rack-2.0.2/test/rack/session/redis_test.rb 2017-04-26 08:49:57.000000000 +0000 +++ ruby-redis-rack-2.1.2/test/rack/session/redis_test.rb 2020-03-13 18:40:42.000000000 +0000 @@ -39,8 +39,9 @@ it "can create it's own pool" do session_store = Rack::Session::Redis.new(incrementor, pool_size: 5, pool_timeout: 10) - session_store.pool.class.must_equal ::ConnectionPool - session_store.pool.instance_variable_get(:@size).must_equal 5 + conn = session_store.instance_variable_get(:@conn) + conn.pool.class.must_equal ::ConnectionPool + conn.pool.instance_variable_get(:@size).must_equal 5 end it "can create it's own pool using default Redis server" do @@ -53,33 +54,77 @@ session_store.with { |connection| connection.to_s.must_match(/127\.0\.0\.1:6380 against DB 1$/) } end - it "can use a supplied pool" do session_store = Rack::Session::Redis.new(incrementor, pool: ::ConnectionPool.new(size: 1, timeout: 1) { ::Redis::Store::Factory.create("redis://127.0.0.1:6380/1")}) - session_store.pool.class.must_equal ::ConnectionPool - session_store.pool.instance_variable_get(:@size).must_equal 1 + conn = session_store.instance_variable_get(:@conn) + conn.pool.class.must_equal ::ConnectionPool + conn.pool.instance_variable_get(:@size).must_equal 1 end it "uses the specified Redis store when provided" do store = ::Redis::Store::Factory.create('redis://127.0.0.1:6380/1') pool = Rack::Session::Redis.new(incrementor, :redis_store => store) - pool.pool.to_s.must_match(/127\.0\.0\.1:6380 against DB 1$/) - pool.pool.must_equal(store) + pool.with do |p| + p.to_s.must_match(/127\.0\.0\.1:6380 against DB 1$/) + p.must_equal(store) + end end it "uses the default Redis server and namespace when not provided" do pool = Rack::Session::Redis.new(incrementor) - pool.pool.to_s.must_match(/127\.0\.0\.1:6379 against DB 0 with namespace rack:session$/) + pool.with { |p| p.to_s.must_match(/127\.0\.0\.1:6379 against DB 0 with namespace rack:session$/) } end it "uses the specified namespace when provided" do pool = Rack::Session::Redis.new(incrementor, :redis_server => {:namespace => 'test:rack:session'}) - pool.pool.to_s.must_match(/namespace test:rack:session$/) + pool.with { |p| p.to_s.must_match(/namespace test:rack:session$/) } end it "uses the specified Redis server when provided" do pool = Rack::Session::Redis.new(incrementor, :redis_server => 'redis://127.0.0.1:6380/1') - pool.pool.to_s.must_match(/127\.0\.0\.1:6380 against DB 1$/) + pool.with { |p| p.to_s.must_match(/127\.0\.0\.1:6380 against DB 1$/) } + end + + it "is threadsafe by default" do + sesion_store = Rack::Session::Redis.new(incrementor) + sesion_store.threadsafe?.must_equal(true) + end + + it "does not store a blank session" do + session_store = Rack::Session::Redis.new(incrementor) + sid = session_store.generate_unique_sid({}) + session_store.with { |c| c.get(sid.private_id).must_be_nil } + end + + it "locks the store mutex" do + mutex = Mutex.new + mutex.expects(:lock).once + sesion_store = Rack::Session::Redis.new(incrementor) + sesion_store.instance_variable_set(:@mutex, mutex) + was_yielded = false + request = Minitest::Mock.new + request.expect(:multithread?, true) + sesion_store.with_lock(request) { was_yielded = true} + was_yielded.must_equal(true) + end + + describe "threadsafe disabled" do + it "can have the global lock disabled" do + sesion_store = Rack::Session::Redis.new(incrementor, :threadsafe => false) + sesion_store.threadsafe?.must_equal(false) + end + + it "does not lock the store mutex" do + mutex = Mutex.new + mutex.expects(:lock).never + sesion_store = Rack::Session::Redis.new(incrementor, :threadsafe => false) + sesion_store.instance_variable_set(:@mutex, mutex) + was_yielded = false + request = Minitest::Mock.new + request.expect(:multithread?, true) + sesion_store.with_lock(request) { was_yielded = true} + was_yielded.must_equal(true) + end end it "creates a new cookie" do @@ -229,15 +274,12 @@ end it "does not hit with :skip option" do - with_pool_management(incrementor) do |pool| - skip = Rack::Utils::Context.new(pool, skip_session) + with_pool_management(incrementor) do |session_store| + skip = Rack::Utils::Context.new(session_store, skip_session) sreq = Rack::MockRequest.new(skip) - pool.instance_variable_set('@pool', MiniTest::Mock.new) - res0 = sreq.get("/") res0.body.must_equal('{"counter"=>1}') - assert pool.pool.verify end end @@ -257,10 +299,11 @@ res0 = req.get("/") session_id = (cookie = res0["Set-Cookie"])[session_match, 1] - ses0 = pool.with { |c| c.get(session_id) } + sid = Rack::Session::SessionId.new(session_id) + ses0 = pool.with { |c| c.get(sid.private_id) } req.get("/", "HTTP_COOKIE" => cookie) - ses1 = pool.with { |c| c.get(session_id) } + ses1 = pool.with { |c| c.get(sid.private_id) } ses1.wont_equal(ses0) end @@ -280,6 +323,7 @@ res.body.must_equal('{"counter"=>1}') cookie = res["Set-Cookie"] session_id = cookie[session_match, 1] + sid = Rack::Session::SessionId.new(session_id) delta_incrementor = lambda do |env| # emulate disconjoinment of threading @@ -301,7 +345,7 @@ request.body.must_include('"counter"=>2') end - session = pool.with { |c| c.get(session_id) } + session = pool.with { |c| c.get(sid.private_id) } session.size.must_equal(tnum+1) # counter session['counter'].must_equal(2) # meeeh @@ -318,7 +362,7 @@ request.body.must_include('"counter"=>3') end - session = pool.with { |c| c.get(session_id) } + session = pool.with { |c| c.get(sid.private_id) } session.size.must_equal(tnum+1) session['counter'].must_equal(3) @@ -340,7 +384,7 @@ request.body.must_include('"foo"=>"bar"') end - session = pool.with { |c| c.get(session_id) } + session = pool.with { |c| c.get(sid.private_id) } session.size.must_equal(r.size+1) session['counter'].must_be_nil session['foo'].must_equal('bar') diff -Nru ruby-redis-rack-2.0.2/test/redis/rack/connection_test.rb ruby-redis-rack-2.1.2/test/redis/rack/connection_test.rb --- ruby-redis-rack-2.0.2/test/redis/rack/connection_test.rb 1970-01-01 00:00:00.000000000 +0000 +++ ruby-redis-rack-2.1.2/test/redis/rack/connection_test.rb 2020-03-13 18:40:42.000000000 +0000 @@ -0,0 +1,84 @@ +require 'test_helper' +require 'connection_pool' +require 'redis/rack/connection' + +class Redis + module Rack + describe Connection do + def setup + @defaults = { + host: 'localhost' + } + end + + it "can create it's own pool" do + conn = Connection.new @defaults.merge(pool_size: 5, pool_timeout: 10) + + conn.pooled?.must_equal true + conn.pool.class.must_equal ConnectionPool + conn.pool.instance_variable_get(:@size).must_equal 5 + end + + it "can create it's own pool using default Redis server" do + conn = Connection.new @defaults.merge(pool_size: 5, pool_timeout: 10) + + conn.pooled?.must_equal true + + conn.with do |connection| + connection.to_s.must_match(/127\.0\.0\.1:6379 against DB 0$/) + end + end + + it "can create it's own pool using provided Redis server" do + conn = Connection.new(redis_server: 'redis://127.0.0.1:6380/1', pool_size: 5, pool_timeout: 10) + conn.pooled?.must_equal true + conn.with do |connection| + connection.to_s.must_match(/127\.0\.0\.1:6380 against DB 1$/) + end + end + + it "can use a supplied pool" do + pool = ConnectionPool.new size: 1, timeout: 1 do + ::Redis::Store::Factory.create('redis://127.0.0.1:6380/1') + end + conn = Connection.new pool: pool + conn.pooled?.must_equal true + conn.pool.class.must_equal ConnectionPool + conn.pool.instance_variable_get(:@size).must_equal 1 + end + + it "uses the specified Redis store when provided" do + store = ::Redis::Store::Factory.create('redis://127.0.0.1:6380/1') + conn = Connection.new(redis_store: store) + + conn.pooled?.must_equal false + conn.store.to_s.must_match(/127\.0\.0\.1:6380 against DB 1$/) + conn.store.must_equal(store) + end + + it "throws an error when provided Redis store is not the expected type" do + assert_raises ArgumentError do + Connection.new(redis_store: ::Redis.new) + end + end + + it "uses the specified Redis server when provided" do + conn = Connection.new(redis_server: 'redis://127.0.0.1:6380/1') + + conn.pooled?.must_equal false + conn.store.to_s.must_match(/127\.0\.0\.1:6380 against DB 1$/) + end + + it "does not include nil options for the connection pool" do + conn = Connection.new + conn.pool_options.must_be_empty + + conn = Connection.new(pool_size: nil) + conn.pool_options.must_be_empty + + conn = Connection.new(pool_timeout: nil) + conn.pool_options.must_be_empty + end + end + end +end diff -Nru ruby-redis-rack-2.0.2/.travis.yml ruby-redis-rack-2.1.2/.travis.yml --- ruby-redis-rack-2.0.2/.travis.yml 2017-04-26 08:49:57.000000000 +0000 +++ ruby-redis-rack-2.1.2/.travis.yml 2020-03-13 18:40:42.000000000 +0000 @@ -1,12 +1,23 @@ language: ruby -script: 'bundle exec rake' +script: bundle exec rake rvm: - - 2.2.3 - - 2.3.1 + - 2.2 + - 2.3 + - 2.4 + - 2.5 + - 2.6 + - 2.7 - ruby-head - jruby-head - matrix: allow_failures: - - rvm: jruby-head - - rvm: ruby-head + - rvm: jruby-head + - rvm: ruby-head +deploy: + provider: rubygems + api_key: + secure: VTosVmCdLWUGK8KyzovYri7ySfd7fACtfL8MClEBBHnI+m2cLCpmtCJ7Z1X7z9BXlj974EDaF8V9iRKzfksXIf8aaPfVQw9AW94fLJZbfSB8YGOGyNbPu9YECoZQB1aZ2lw9s/aEdfwCbmqizO/fYpG3YoPKJdm1ZJpNOFR37Xk= + gem: redis-rack + on: + tags: true + repo: redis-store/redis-rack