redis-session-store 0.1.8 → 0.1.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (5) hide show
  1. data/LICENSE +3 -1
  2. data/README.md +6 -1
  3. data/Rakefile +2 -23
  4. data/lib/redis-session-store.rb +8 -15
  5. metadata +36 -55
data/LICENSE CHANGED
@@ -1,5 +1,7 @@
1
1
  Copyright (c) 2009 Mathias Meyer
2
2
 
3
+ MIT License
4
+
3
5
  Permission is hereby granted, free of charge, to any person obtaining
4
6
  a copy of this software and associated documentation files (the
5
7
  "Software"), to deal in the Software without restriction, including
@@ -17,4 +19,4 @@ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
19
  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
20
  LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
21
  OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md CHANGED
@@ -34,4 +34,9 @@ Set them using:
34
34
  In your Rails app, throw in an initializer with the following contents
35
35
  and the configuration above:
36
36
 
37
- ActionController::Base.session_store = RedisSessionStore
37
+ ActionController::Base.session_store = RedisSessionStore
38
+
39
+ Changes
40
+ =======
41
+
42
+ * Use setex for a single command instead of sending two commands. (Thanks dplummer)
data/Rakefile CHANGED
@@ -1,23 +1,2 @@
1
- require 'rubygems'
2
- require 'rake/gempackagetask'
3
- require 'rubygems/specification'
4
-
5
- spec = Gem::Specification.new do |s|
6
- s.name = 'redis-session-store'
7
- s.version = '0.1.8'
8
- s.platform = Gem::Platform::RUBY
9
- s.has_rdoc = true
10
- s.extra_rdoc_files = ["LICENSE"]
11
- s.summary = "A drop-in replacement for e.g. MemCacheStore to store Rails sessions (and Rails sessions only) in Redis."
12
- s.description = s.summary
13
- s.authors = "Mathias Meyer"
14
- s.email = "meyer@paperplanes.de"
15
- s.homepage = "http://github.com/mattmatt/redis-session-store"
16
- s.add_dependency "redis"
17
- s.require_path = 'lib'
18
- s.files = %w(README.md Rakefile) + Dir.glob("{lib}/**/*")
19
- end
20
-
21
- Rake::GemPackageTask.new(spec) do |pkg|
22
- pkg.gem_spec = spec
23
- end
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
@@ -15,18 +15,11 @@ require 'redis'
15
15
  class RedisSessionStore < ActionController::Session::AbstractStore
16
16
 
17
17
  def initialize(app, options = {})
18
- # Support old :expires option
19
- options[:expire_after] ||= options[:expires]
20
-
21
18
  super
22
19
 
23
20
  @default_options = {
24
- :namespace => 'rack:session',
25
- :host => 'localhost',
26
- :port => '6379',
27
- :db => 0,
28
- :key_prefix => ""
29
- }.update(options)
21
+ :namespace => 'rack:session'
22
+ }.merge(options)
30
23
 
31
24
  @redis = Redis.new(@default_options)
32
25
  end
@@ -35,7 +28,7 @@ class RedisSessionStore < ActionController::Session::AbstractStore
35
28
  def prefixed(sid)
36
29
  "#{@default_options[:key_prefix]}#{sid}"
37
30
  end
38
-
31
+
39
32
  def get_session(env, sid)
40
33
  sid ||= generate_sid
41
34
  begin
@@ -50,13 +43,13 @@ class RedisSessionStore < ActionController::Session::AbstractStore
50
43
  def set_session(env, sid, session_data)
51
44
  options = env['rack.session.options']
52
45
  expiry = options[:expire_after] || nil
53
-
54
- @redis.set(prefixed(sid), Marshal.dump(session_data))
55
- @redis.expire(prefixed(sid), expiry) if expiry
56
-
46
+ if expiry
47
+ @redis.setex(prefixed(sid), expiry, Marshal.dump(session_data))
48
+ else
49
+ @redis.set(prefixed(sid), Marshal.dump(session_data))
50
+ end
57
51
  return true
58
52
  rescue Errno::ECONNREFUSED
59
53
  return false
60
54
  end
61
-
62
55
  end
metadata CHANGED
@@ -1,83 +1,64 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: redis-session-store
3
- version: !ruby/object:Gem::Version
4
- hash: 11
5
- prerelease: false
6
- segments:
7
- - 0
8
- - 1
9
- - 8
10
- version: 0.1.8
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.9
5
+ prerelease:
11
6
  platform: ruby
12
- authors:
7
+ authors:
13
8
  - Mathias Meyer
14
9
  autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
-
18
- date: 2010-12-10 00:00:00 +01:00
19
- default_executable:
20
- dependencies:
21
- - !ruby/object:Gem::Dependency
12
+ date: 2012-03-06 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
22
15
  name: redis
23
- prerelease: false
24
- requirement: &id001 !ruby/object:Gem::Requirement
16
+ requirement: &70198775254380 !ruby/object:Gem::Requirement
25
17
  none: false
26
- requirements:
27
- - - ">="
28
- - !ruby/object:Gem::Version
29
- hash: 3
30
- segments:
31
- - 0
32
- version: "0"
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
33
22
  type: :runtime
34
- version_requirements: *id001
35
- description: A drop-in replacement for e.g. MemCacheStore to store Rails sessions (and Rails sessions only) in Redis.
36
- email: meyer@paperplanes.de
23
+ prerelease: false
24
+ version_requirements: *70198775254380
25
+ description: A drop-in replacement for e.g. MemCacheStore to store Rails sessions
26
+ (and Rails sessions only) in Redis.
27
+ email:
28
+ - meyer@paperplanes.de
37
29
  executables: []
38
-
39
30
  extensions: []
40
-
41
- extra_rdoc_files:
31
+ extra_rdoc_files:
42
32
  - LICENSE
43
- files:
33
+ files:
44
34
  - README.md
45
35
  - Rakefile
46
36
  - lib/redis-session-store.rb
47
37
  - LICENSE
48
- has_rdoc: true
49
38
  homepage: http://github.com/mattmatt/redis-session-store
50
39
  licenses: []
51
-
52
40
  post_install_message:
53
41
  rdoc_options: []
54
-
55
- require_paths:
42
+ require_paths:
56
43
  - lib
57
- required_ruby_version: !ruby/object:Gem::Requirement
44
+ required_ruby_version: !ruby/object:Gem::Requirement
58
45
  none: false
59
- requirements:
60
- - - ">="
61
- - !ruby/object:Gem::Version
62
- hash: 3
63
- segments:
64
- - 0
65
- version: "0"
66
- required_rubygems_version: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - ! '>='
48
+ - !ruby/object:Gem::Version
49
+ version: '0'
50
+ required_rubygems_version: !ruby/object:Gem::Requirement
67
51
  none: false
68
- requirements:
69
- - - ">="
70
- - !ruby/object:Gem::Version
71
- hash: 3
72
- segments:
73
- - 0
74
- version: "0"
52
+ requirements:
53
+ - - ! '>='
54
+ - !ruby/object:Gem::Version
55
+ version: '0'
75
56
  requirements: []
76
-
77
57
  rubyforge_project:
78
- rubygems_version: 1.3.7
58
+ rubygems_version: 1.8.11
79
59
  signing_key:
80
60
  specification_version: 3
81
- summary: A drop-in replacement for e.g. MemCacheStore to store Rails sessions (and Rails sessions only) in Redis.
61
+ summary: A drop-in replacement for e.g. MemCacheStore to store Rails sessions (and
62
+ Rails sessions only) in Redis.
82
63
  test_files: []
83
-
64
+ has_rdoc: true