Class: ActionDispatch::Session::IronCache

Inherits:
AbstractStore
  • Object
show all
Defined in:
lib/action_dispatch/session/iron_cache.rb

Instance Method Summary collapse

Constructor Details

#initialize(app, options = {}) ⇒ IronCache



9
10
11
12
13
14
# File 'lib/action_dispatch/session/iron_cache.rb', line 9

def initialize(app, options = {})
  @options = options
  super

  @client = ::IronCache::Client.new(options)
end

Instance Method Details

#destroy_session(env, session_id, options = {}) ⇒ Object



42
43
44
45
46
47
48
# File 'lib/action_dispatch/session/iron_cache.rb', line 42

def destroy_session(env, session_id, options={})
  with_namespace(session_id, options) do |cache, k|
    cache.delete(k) rescue nil
  end

  generate_sid
end

#get_session(env, session_id) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/action_dispatch/session/iron_cache.rb', line 20

def get_session(env, session_id)
  item = nil
  session_id ||= generate_sid

  with_namespace(session_id, options) do |cache, k|
    item = cache.get(k)
    item = item.value unless item.nil?
  end

  session_data = deserialize_entry(item) rescue {}

  [session_id, session_data]
end

#optionsObject



16
17
18
# File 'lib/action_dispatch/session/iron_cache.rb', line 16

def options
  @options
end

#set_session(env, session_id, session, options = {}) ⇒ Object



34
35
36
37
38
39
40
# File 'lib/action_dispatch/session/iron_cache.rb', line 34

def set_session(env, session_id, session, options={})
  with_namespace(session_id, options) do |cache, k|
    cache.put(k, serialize_entry(session, options), options)
  end

  session_id
end