easy_redis 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +22 -16
- data/lib/easy_redis/easy_redis.rb +4 -3
- data/lib/easy_redis/errors/non_existent_object_error.rb +7 -0
- data/lib/easy_redis/methods/getters.rb +1 -1
- data/lib/easy_redis/methods/methods.rb +1 -6
- data/lib/easy_redis/version/version.rb +1 -1
- metadata +13 -14
- data/lib/easy_redis/methods/updaters.rb +0 -20
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 195815edfacb1c85290d569e268c67090b4233d4
|
4
|
+
data.tar.gz: af059c901a40e331a20a992fd2c9be05c3ce8aa0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c2973d34dcba12294e95a43b44ea14301007a4ba8566aa1b67df32448ab9128e7c509fc276e7a3e2c2f710a6b506fda319bae31a7e9964930c13e4b8fb5724bc
|
7
|
+
data.tar.gz: 7c3648c87aab8d5578cc50d64b56adf916c93bd80fca166149a53191e1c36cb83096866a0e8b0a93df4998c8b4878b86ed4bac3942c1d83a316d8638fa694c79
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# EasyRedis
|
2
2
|
|
3
|
-
Helper methods for activerecord objects to use redis easily
|
3
|
+
Helper methods for activerecord objects to use redis easily.
|
4
4
|
Don't worry about the type casting. EasyRedis does type conversions!
|
5
5
|
|
6
6
|
## Installation
|
@@ -19,28 +19,34 @@ Or install it yourself as:
|
|
19
19
|
|
20
20
|
## Usage
|
21
21
|
|
22
|
-
Create a file under initializers directory and set a redis client like
|
22
|
+
Create a file under initializers directory and set a redis client like below:
|
23
|
+
|
24
|
+
EasyRedis::Redis.configure(redis: Redis.new)
|
23
25
|
|
24
|
-
EasyRedis::Redis.configure(:redis => Redis.new)
|
25
26
|
|
26
27
|
Examples:
|
27
28
|
|
28
|
-
u = User.find(1)
|
29
|
-
u.r_set("
|
30
|
-
u.
|
31
|
-
u.
|
29
|
+
u = User.find(1) #sample ActiveRecord object
|
30
|
+
u.r_set("foo", "bar")
|
31
|
+
u.r_set_foo("bar")
|
32
|
+
u.redis_set("foo", "bar")
|
33
|
+
u.redis_set_foo("bar")
|
34
|
+
|
35
|
+
u.r_get("foo")
|
36
|
+
u.r_get_foo
|
37
|
+
u.redis_get("foo")
|
38
|
+
u.redis_get_foo
|
32
39
|
|
33
|
-
u.
|
34
|
-
u.
|
35
|
-
u.
|
40
|
+
u.r_del("foo")
|
41
|
+
u.r_del_foo
|
42
|
+
u.redis_del("foo")
|
43
|
+
u.redis_del_foo
|
36
44
|
|
37
|
-
u.
|
38
|
-
u.
|
39
|
-
u.redis_del_key
|
45
|
+
u.r_set_foo true
|
46
|
+
u.r_get_foo #returns true
|
40
47
|
|
41
|
-
u.
|
42
|
-
u.
|
43
|
-
u.redis_update_key("value")
|
48
|
+
u.r_set_foo 1
|
49
|
+
u.r_get_foo #returns 1
|
44
50
|
|
45
51
|
## Contributing
|
46
52
|
|
@@ -1,4 +1,5 @@
|
|
1
1
|
require "easy_redis/version/version"
|
2
|
+
require "easy_redis/errors/non_existent_object_error"
|
2
3
|
require "easy_redis/initialize/active_record"
|
3
4
|
|
4
5
|
module EasyRedis
|
@@ -8,7 +9,7 @@ module EasyRedis
|
|
8
9
|
@@redis = nil
|
9
10
|
@@config = {
|
10
11
|
namespace: "easyredis",
|
11
|
-
|
12
|
+
raise_non_existent_object_error: true,
|
12
13
|
redis: nil
|
13
14
|
}
|
14
15
|
@@valid_config_keys = @@config.keys
|
@@ -27,8 +28,8 @@ module EasyRedis
|
|
27
28
|
@@config[:namespace]
|
28
29
|
end
|
29
30
|
|
30
|
-
def
|
31
|
-
@@config[:
|
31
|
+
def raise_non_existent_object_error?
|
32
|
+
@@config[:raise_non_existent_object_error]
|
32
33
|
end
|
33
34
|
|
34
35
|
def configure(opts = {})
|
@@ -1,7 +1,6 @@
|
|
1
1
|
require "easy_redis/methods/getters"
|
2
2
|
require "easy_redis/methods/setters"
|
3
3
|
require "easy_redis/methods/deleters"
|
4
|
-
require "easy_redis/methods/updaters"
|
5
4
|
|
6
5
|
module EasyRedis
|
7
6
|
|
@@ -12,11 +11,11 @@ module EasyRedis
|
|
12
11
|
include EasyRedis::Getters
|
13
12
|
include EasyRedis::Setters
|
14
13
|
include EasyRedis::Deleters
|
15
|
-
include EasyRedis::Updaters
|
16
14
|
end
|
17
15
|
end
|
18
16
|
|
19
17
|
def redis_key
|
18
|
+
raise NonExistentObjectError if self.new_record? && EasyRedis::Redis.raise_non_existent_object_error?
|
20
19
|
@redis_key ||= "#{EasyRedis::Redis.namespace}:attributes:#{self.class.name}:#{self.id}"
|
21
20
|
end
|
22
21
|
|
@@ -24,10 +23,6 @@ module EasyRedis
|
|
24
23
|
EasyRedis::Redis.redis
|
25
24
|
end
|
26
25
|
|
27
|
-
def use_type_casting?
|
28
|
-
EasyRedis::Redis.use_type_casting?
|
29
|
-
end
|
30
|
-
|
31
26
|
end
|
32
27
|
|
33
28
|
end
|
metadata
CHANGED
@@ -1,55 +1,55 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: easy_redis
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mehmet Emin İNAÇ
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-06
|
11
|
+
date: 2014-07-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: redis
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - '>='
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - '>='
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: bundler
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - ~>
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '1.6'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - ~>
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '1.6'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rake
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- -
|
45
|
+
- - '>='
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '0'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- -
|
52
|
+
- - '>='
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
55
|
description: Creates getter and setter methods for redis store.
|
@@ -59,7 +59,7 @@ executables: []
|
|
59
59
|
extensions: []
|
60
60
|
extra_rdoc_files: []
|
61
61
|
files:
|
62
|
-
-
|
62
|
+
- .gitignore
|
63
63
|
- Gemfile
|
64
64
|
- LICENSE.txt
|
65
65
|
- README.md
|
@@ -67,12 +67,12 @@ files:
|
|
67
67
|
- easy_redis.gemspec
|
68
68
|
- lib/easy_redis.rb
|
69
69
|
- lib/easy_redis/easy_redis.rb
|
70
|
+
- lib/easy_redis/errors/non_existent_object_error.rb
|
70
71
|
- lib/easy_redis/initialize/active_record.rb
|
71
72
|
- lib/easy_redis/methods/deleters.rb
|
72
73
|
- lib/easy_redis/methods/getters.rb
|
73
74
|
- lib/easy_redis/methods/methods.rb
|
74
75
|
- lib/easy_redis/methods/setters.rb
|
75
|
-
- lib/easy_redis/methods/updaters.rb
|
76
76
|
- lib/easy_redis/version/version.rb
|
77
77
|
homepage: http://github.com/meinac/easy_redis
|
78
78
|
licenses:
|
@@ -84,19 +84,18 @@ require_paths:
|
|
84
84
|
- lib
|
85
85
|
required_ruby_version: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
|
-
- -
|
87
|
+
- - '>='
|
88
88
|
- !ruby/object:Gem::Version
|
89
89
|
version: '0'
|
90
90
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
91
91
|
requirements:
|
92
|
-
- -
|
92
|
+
- - '>='
|
93
93
|
- !ruby/object:Gem::Version
|
94
94
|
version: '0'
|
95
95
|
requirements: []
|
96
96
|
rubyforge_project:
|
97
|
-
rubygems_version: 2.
|
97
|
+
rubygems_version: 2.0.3
|
98
98
|
signing_key:
|
99
99
|
specification_version: 4
|
100
100
|
summary: Less coding for redis store
|
101
101
|
test_files: []
|
102
|
-
has_rdoc:
|
@@ -1,20 +0,0 @@
|
|
1
|
-
module EasyRedis
|
2
|
-
|
3
|
-
module Updaters
|
4
|
-
|
5
|
-
def r_update(attribute, value)
|
6
|
-
self.r_del(attribute)
|
7
|
-
self.r_set(attribute, value)
|
8
|
-
end
|
9
|
-
|
10
|
-
def method_missing(meth, *args, &block)
|
11
|
-
(meth.to_s =~ /^redis_update_(.+)$/ || meth.to_s =~ /^r_update_(.+)$/) ? r_delete($1, *args) : super
|
12
|
-
end
|
13
|
-
|
14
|
-
alias_method :redis_update, :r_update
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
end
|
19
|
-
|
20
|
-
end
|