Skip to content

Commit

Permalink
added code to delete entry from concurrent hash(need review)
Browse files Browse the repository at this point in the history
  • Loading branch information
pulkit4tech committed Jun 20, 2016
1 parent 601fc7e commit 0180159
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions lib/reel/session/store.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ module Reel
module Session
class Store
include Crypto
include Celluloid

def initialize request

Expand Down Expand Up @@ -32,11 +33,20 @@ def generate_id
Celluloid::Internals::UUID.generate
end

# start Celluloid timer to delete value from concurrent hash after expiry
def start_timer
return unless @key
@delete_time = after(@config[:session_length]){
@store.delete @key if @store
}
end

def save
return nil if @val.empty?
return if @val.empty?
# merge key,value
@key ||= generate_id
@key = generate_id
@store.merge!({@key=>@val})
start_timer
@key
end

Expand Down

1 comment on commit 0180159

@pulkit4tech
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will we do something like this for deleting session value from Concurrent Hash after expiry ?
/cc: @kenichi @digitalextremist

Please sign in to comment.