xunch 0.0.11 → 0.0.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/xunch/cache/cache_builder.rb +16 -5
- data/lib/xunch/codec/hash_codec.rb +8 -6
- data/lib/xunch/codec/json_codec.rb +5 -3
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b014c083ed1eb56f9e11819d41f72e9f3fb91f5e
|
4
|
+
data.tar.gz: 4be135a5587d36b2bb0d45372fc709dbdeb7c7d3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0d473177324e31e4aee69ed43d65482bae3303b2332ff1e2b166c5b7772c17414d5a93e907d33ab0253fc592b521c1a66e3dc7b61bd6680757a8b243a796ba2c
|
7
|
+
data.tar.gz: 20bddd0b63a3537fbc6afca02677c82fbbef78eb7de494fc057facbb8886125c027a7fec41ac7c7326e9ce8c874df9273778807321377a47b580c53d808bb7ff
|
@@ -25,12 +25,19 @@ module Xunch
|
|
25
25
|
}
|
26
26
|
caches = {}
|
27
27
|
lazy_caches = {}
|
28
|
-
cache_configs.
|
28
|
+
cache_configs.each { |cache_key, cache_config|
|
29
|
+
puts "loading cache #{cache_key} #{cache_config}"
|
29
30
|
if cache_config["type"] == nil
|
30
|
-
raise ArgumentError.new("cache type can't be nil.")
|
31
|
+
raise ArgumentError.new("#{cache_key} cache type can't be nil.")
|
32
|
+
end
|
33
|
+
if cache_config["shards"] == nil
|
34
|
+
raise ArgumentError.new("#{cache_key} cache shards can't be nil.")
|
31
35
|
end
|
32
36
|
shard_names = cache_config["shards"].split(",")
|
33
|
-
|
37
|
+
if cache_config["driver"]
|
38
|
+
driver = cache_config["driver"].downcase.to_sym
|
39
|
+
puts "#{cache_key} use redis driver #{driver}"
|
40
|
+
end
|
34
41
|
shard_infos = []
|
35
42
|
shard_size = shard_names.size
|
36
43
|
shard_names.each { |shard|
|
@@ -41,7 +48,7 @@ module Xunch
|
|
41
48
|
if driver
|
42
49
|
shard_options[:driver] = driver
|
43
50
|
if shard_options[:driver] == :synchrony and cache_config["type"].start_with?("list")
|
44
|
-
raise ArgumentError.new("list cache can't use synchrony driver.")
|
51
|
+
raise ArgumentError.new("list cache can't use synchrony driver. cache key is #{cache_key}")
|
45
52
|
end
|
46
53
|
end
|
47
54
|
if cache_config["timeout"]
|
@@ -56,7 +63,11 @@ module Xunch
|
|
56
63
|
if weight
|
57
64
|
shard_options[:weight] = weight.to_i
|
58
65
|
end
|
59
|
-
|
66
|
+
if shards[shard_name]
|
67
|
+
shard_options.merge!(shards[shard_name])
|
68
|
+
else
|
69
|
+
raise ArgumentError.new("Unknown shard #{shard_name}, initialize cache #{cache_key} failed.")
|
70
|
+
end
|
60
71
|
shard_infos.push(ShardInfo.new(shard_options))
|
61
72
|
}
|
62
73
|
case cache_config["type"]
|
@@ -28,12 +28,14 @@ module Xunch
|
|
28
28
|
end
|
29
29
|
hash = Hash.new
|
30
30
|
@get_methods.each do | k , v |
|
31
|
-
|
32
|
-
|
33
|
-
if var_value
|
34
|
-
|
35
|
-
|
36
|
-
|
31
|
+
if value.has_attribute?(v)
|
32
|
+
var_value = value.send(v)
|
33
|
+
if var_value != nil
|
34
|
+
if var_value.class.name == Time.name or var_value.class.name == DateTime.name
|
35
|
+
hash[k] = var_value.strftime(DEFAULT_DATE_FORMAT)
|
36
|
+
else
|
37
|
+
hash[k] = var_value
|
38
|
+
end
|
37
39
|
end
|
38
40
|
end
|
39
41
|
end
|
@@ -16,9 +16,11 @@ module Xunch
|
|
16
16
|
end
|
17
17
|
hash = Hash.new
|
18
18
|
@get_methods.each do | k , v |
|
19
|
-
|
20
|
-
|
21
|
-
|
19
|
+
if value.has_attribute?(v)
|
20
|
+
var_value = value.send(v)
|
21
|
+
if var_value != nil
|
22
|
+
hash[k] = var_value
|
23
|
+
end
|
22
24
|
end
|
23
25
|
end
|
24
26
|
Yajl::Encoder.encode(hash)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: xunch
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.12
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ted Wang
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-07-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: redis
|
@@ -16,26 +16,26 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ~>
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 3.0
|
19
|
+
version: '3.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
|
-
version: 3.0
|
26
|
+
version: '3.0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: murmurhash
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - '='
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: 0.0.1
|
34
34
|
type: :runtime
|
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: 0.0.1
|
41
41
|
description: cache client
|