Class: Zetto::Storage::Session::FindBySession

Inherits:
Object
  • Object
show all
Defined in:
lib/zetto/storage/session/find_by_session.rb

Instance Method Summary collapse

Constructor Details

#initialize(session_id) ⇒ FindBySession

Returns a new instance of FindBySession.



6
7
8
9
# File 'lib/zetto/storage/session/find_by_session.rb', line 6

def initialize(session_id)
  @redis = Zetto::Storage::Connect::RedisSingelton.get
  @session_id = session_id
end

Instance Method Details

#executeObject



11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/zetto/storage/session/find_by_session.rb', line 11

def execute
  begin
    key = "session:" + @session_id.to_s
    data = {}
    data = @redis.hgetall(key)
    data['time_live_s'] = @redis.ttl(key)
    data["session_id"] = @session_id.to_s
    return Zetto::Storage::Session::Data::Response.new(data)
  rescue Exception => e
    Zetto::Services::Info.error_message I18n.t('exseptions.unknown_error', argument: 'Zetto::Storage::Session::FindBySession', current_method: __method__), e
    nil
  end
end