sinatra-redis-cache 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8fddb41084d855236180b8f318398cacf0ca4339
4
- data.tar.gz: 011f08ff6d8b377e71f13d2c26b867fb8840bebe
3
+ metadata.gz: 1eb442534222edecf64af54d30a45a7c1d8fe559
4
+ data.tar.gz: 9128065c4109646cd63074474d5f0e11504eab0c
5
5
  SHA512:
6
- metadata.gz: 9f187012a94865f91273d809d57badadb5bd47f0476d79e91e66989212f2eab63e74cf2d61f25bdde0c74180b8f576d7b8dcf0cce0f074ab719a7f90da35bded
7
- data.tar.gz: 6f4ee2343b063daa6077301382ee00bbc2e2adaeca390939f6be444e06c65b64befa8bcd36b0bb6eac0da66ed02502013d8a9988c0b5c856d80be204b67c3248
6
+ metadata.gz: 0fcd35646a58cd5019cdd7e2cc810df0f0e5704d410a3e91fd1c6abf14594d87c348d5ffb796d7dac45a370a0e817b761af6df9248e6baf19476503944d415dd
7
+ data.tar.gz: 9620aa4fd0273217853849a684e846ecfa2a199587b9e89b4d50c3399384d2b59dd8d614bcd47fbf35e8419d305f820c72684891fffe55e6d229a2378fd90ef7
data/README.md CHANGED
@@ -7,7 +7,8 @@ A simple redis backed cache for Sinatra applications.
7
7
  * Add the gem to your Gemfile
8
8
 
9
9
  ```ruby
10
- gem 'sinatra-redis-cache', git: 'https://github.com/warrenguy/sinatra-redis-cache.git'
10
+ source 'https://rubygems.org'
11
+ gem 'sinatra-redis-cache'
11
12
  ```
12
13
 
13
14
  * Require it in your app after including Sinatra
data/Rakefile CHANGED
@@ -8,6 +8,6 @@ namespace :sinatra_cache do
8
8
  desc 'Print configured namespace'
9
9
  task :namespace do
10
10
  include Sinatra::RedisCache
11
- Sinatra::RedisCache.config.namespace
11
+ Sinatra::RedisCache::Config.config.namespace
12
12
  end
13
13
  end
@@ -48,16 +48,29 @@ module Sinatra
48
48
 
49
49
  def get(key, params={})
50
50
  key = key_with_namespace(key)
51
- redis.get(key)
51
+ string = redis.get(key)
52
+ unless string.nil?
53
+ deserialize(string)
54
+ else
55
+ false
56
+ end
52
57
  end
53
58
 
54
- def store(key, value, expires, params={})
59
+ def store(key, object, expires, params={})
55
60
  key = key_with_namespace(key)
56
61
  expires = expires || config.default_expires
57
- redis.set(key, value)
62
+ redis.set(key, serialize(object))
58
63
  redis.expire(key, expires)
59
64
  end
60
65
 
66
+ def serialize(object)
67
+ Marshal.dump(object)
68
+ end
69
+
70
+ def deserialize(string)
71
+ Marshal.load(string)
72
+ end
73
+
61
74
  def flush
62
75
  redis.del(all_keys)
63
76
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sinatra-redis-cache
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Warren Guy