couchbase-id 1.0.4 → 1.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/couchbase-id/generator.rb +6 -8
- data/lib/couchbase-id/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 17a624b57deb062a71a3d26c05d8002508e9397d
|
4
|
+
data.tar.gz: eecf62f4e9f3385252796cea40dee43035588792
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5ea51e602a1522fe81ee1b76e11ccdd721a651f19081342bb32fd02d00b68eb95cae1fc7dd605311af1e3e16bebc3fda4f5e513bdc2f9554b0286660ce910c8f
|
7
|
+
data.tar.gz: 42525f06fc2df7cf0008c095b936870764ac25bea5270f11f683e29a7eed12f144968e185aa4f09271a083194b79d4e0df5360f3192b29131fb08f633979855c
|
@@ -38,14 +38,14 @@ module CouchbaseId
|
|
38
38
|
#
|
39
39
|
# Generate the id (incrementing values as required)
|
40
40
|
#
|
41
|
-
overflow = self.class.__overflow__ ||= self.class.bucket.get("#{self.class.
|
42
|
-
count = self.class.bucket.incr("#{self.class.
|
41
|
+
overflow = self.class.__overflow__ ||= self.class.bucket.get("#{self.class.design_document}:#{CLUSTER_ID}:overflow", :quiet => true) # Don't error if not there
|
42
|
+
count = self.class.bucket.incr("#{self.class.design_document}:#{CLUSTER_ID}:count", :create => true) # This models current id count
|
43
43
|
if count == 0 || overflow.nil?
|
44
44
|
overflow ||= 0
|
45
45
|
overflow += 1
|
46
46
|
# We shouldn't need to worry about concurrency here due to the size of count
|
47
47
|
# Would require ~18446744073709551615 concurrent writes
|
48
|
-
self.class.bucket.set("#{self.class.
|
48
|
+
self.class.bucket.set("#{self.class.design_document}:#{CLUSTER_ID}:overflow", overflow)
|
49
49
|
self.class.__overflow__ = overflow
|
50
50
|
end
|
51
51
|
|
@@ -63,8 +63,8 @@ module CouchbaseId
|
|
63
63
|
while self.class.bucket.get(self.id, :quiet => true).present?
|
64
64
|
# Set in-case we are here due to a crash (concurrency is not an issue)
|
65
65
|
# Note we are not incrementing the @__overflow__ variable
|
66
|
-
self.class.bucket.set("#{self.class.
|
67
|
-
count = self.class.bucket.incr("#{self.class.
|
66
|
+
self.class.bucket.set("#{self.class.design_document}:#{CLUSTER_ID}:overflow", overflow + 1)
|
67
|
+
count = self.class.bucket.incr("#{self.class.design_document}:#{CLUSTER_ID}:count") # Increment just in case (attempt to avoid infinite loops)
|
68
68
|
|
69
69
|
# Reset the overflow
|
70
70
|
if self.class.__overflow__ == overflow
|
@@ -81,7 +81,6 @@ module CouchbaseId
|
|
81
81
|
class << base
|
82
82
|
attr_accessor :__overflow__
|
83
83
|
attr_accessor :__class_id_generator__
|
84
|
-
attr_accessor :__class_name__
|
85
84
|
end
|
86
85
|
|
87
86
|
|
@@ -96,7 +95,7 @@ module CouchbaseId
|
|
96
95
|
|
97
96
|
def self.default_class_id_generator(overflow, count)
|
98
97
|
id = Radix.convert([overflow, CLUSTER_ID].join.to_i, B10, B65) + Radix.convert(count, B10, B65)
|
99
|
-
"#{self.
|
98
|
+
"#{self.design_document}-#{id}"
|
100
99
|
end
|
101
100
|
|
102
101
|
#
|
@@ -111,7 +110,6 @@ module CouchbaseId
|
|
111
110
|
# Configure class level variables
|
112
111
|
base.__overflow__ = nil
|
113
112
|
base.__class_id_generator__ = method(:default_class_id_generator)
|
114
|
-
base.__class_name__ = self.name.underscore.gsub(/\/|_/, '-') # The included classes name
|
115
113
|
end
|
116
114
|
end
|
117
115
|
end # END:: Generator
|
data/lib/couchbase-id/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: couchbase-id
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stephen von Takach
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-12-
|
11
|
+
date: 2013-12-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: couchbase-model
|