Class: Rack::Session::Redic::Storage
- Inherits:
-
Object
- Object
- Rack::Session::Redic::Storage
- Defined in:
- lib/rack/session/redic.rb
Overview
A wrapper around Redic to simplify calls.
Constant Summary collapse
- DELETE =
Redis commands.
'DEL'.freeze
- EX =
'EX'.freeze
- EXISTS =
'EXISTS'.freeze
- GET =
'GET'.freeze
- SET =
'SET'.freeze
- PACK =
Assorted.
'm'.freeze
- ZERO =
0
Instance Method Summary collapse
- #delete(id) ⇒ Object
- #exists?(id) ⇒ Boolean
- #get(id) ⇒ Object
-
#initialize(expires, marshaller, url) ⇒ Storage
constructor
A new instance of Storage.
- #set(id, object) ⇒ Object
Constructor Details
#initialize(expires, marshaller, url) ⇒ Storage
Returns a new instance of Storage.
95 96 97 98 99 |
# File 'lib/rack/session/redic.rb', line 95 def initialize(expires, marshaller, url) @expires = expires @marshaller = marshaller @storage = ::Redic.new(url) end |
Instance Method Details
#delete(id) ⇒ Object
116 117 118 |
# File 'lib/rack/session/redic.rb', line 116 def delete(id) @storage.call(DELETE, id) end |
#exists?(id) ⇒ Boolean
101 102 103 |
# File 'lib/rack/session/redic.rb', line 101 def exists?(id) @storage.call(EXISTS, id) != ZERO end |
#get(id) ⇒ Object
105 106 107 |
# File 'lib/rack/session/redic.rb', line 105 def get(id) deserialize(@storage.call(GET, id)) end |