active_record_shards 2.6.3 → 2.6.4

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.
@@ -30,15 +30,19 @@ module ActiveRecordShards
30
30
  end
31
31
 
32
32
  def shard_name(klass = nil, try_slave = true)
33
- s = ActiveRecordShards.rails_env.dup
34
- if the_shard = shard(klass)
35
- s << '_shard_'
36
- s << the_shard
37
- end
38
- if @on_slave && try_slave
39
- s << "_slave" if @on_slave
33
+ the_shard = shard(klass)
34
+
35
+ # Tradeoff: An Array is a slower Hash key, but joining its elements into
36
+ # one string would generate 3 new String objects needing GC later.
37
+ key = [the_shard, try_slave, @on_slave]
38
+
39
+ @shard_names ||= {}
40
+ @shard_names[key] ||= begin
41
+ s = ActiveRecordShards.rails_env.dup
42
+ s << "_shard_#{the_shard}" if the_shard
43
+ s << "_slave" if @on_slave && try_slave
44
+ s
40
45
  end
41
- s
42
46
  end
43
47
 
44
48
  def options
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_record_shards
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.6.3
4
+ version: 2.6.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2012-05-10 00:00:00.000000000 Z
14
+ date: 2012-06-07 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: activerecord
@@ -224,18 +224,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
224
224
  - - ! '>='
225
225
  - !ruby/object:Gem::Version
226
226
  version: '0'
227
- segments:
228
- - 0
229
- hash: 2639893449143032567
230
227
  required_rubygems_version: !ruby/object:Gem::Requirement
231
228
  none: false
232
229
  requirements:
233
230
  - - ! '>='
234
231
  - !ruby/object:Gem::Version
235
232
  version: '0'
236
- segments:
237
- - 0
238
- hash: 2639893449143032567
239
233
  requirements: []
240
234
  rubyforge_project:
241
235
  rubygems_version: 1.8.24