Skip to content

Commit

Permalink
extract options from TokenStore.aquire
Browse files Browse the repository at this point in the history
  • Loading branch information
kbrock committed Oct 6, 2020
1 parent cea384c commit 8b4af88
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions lib/token_store.rb
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
class TokenStore
@token_caches = {} # Hash of Memory/Dalli Store Caches, Keyed by namespace

# only used by TokenManager.token_store
# @return a token store for users
def self.acquire(namespace, token_ttl)
@token_caches[namespace] ||= begin
options = cache_store_options(namespace, token_ttl)
case ::Settings.server.session_store
when "sql"
SqlStore.new(cache_store_options(namespace, token_ttl))
SqlStore.new(options)
when "memory"
require 'active_support/cache/memory_store'
ActiveSupport::Cache::MemoryStore.new(cache_store_options(namespace, token_ttl))
ActiveSupport::Cache::MemoryStore.new(options)
when "cache"
require 'active_support/cache/dalli_store'
ActiveSupport::Cache::DalliStore.new(MiqMemcached.server_address, cache_store_options(namespace, token_ttl))
ActiveSupport::Cache::DalliStore.new(MiqMemcached.server_address, options)
else
raise "unsupported session store type: #{::Settings.server.session_store}"
end
Expand Down

0 comments on commit 8b4af88

Please sign in to comment.