torquebox-cache 3.0.0-java → 3.0.1-java

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 508f24d56d7bf5191574deb27ca1eccf12d99683
4
+ data.tar.gz: 780810ff535b6dd439336a67e02382e19edfc19a
5
+ SHA512:
6
+ metadata.gz: 70faed5c15b0aea796c92c46c82459a58d440ae87a5c09a1720ca9720a79375f99d06badbbd616581f786ac7e18b3ed96d1428a152a5d154e7d66edf3e7c064c
7
+ data.tar.gz: 921b2704c61dc783173950510e71b0b936d6d63fc44766135bd4199356d948154dd23ff68d1b96c351941da69e3c4cc0336b6275583be5a7761185b87726100a
Binary file
@@ -1,6 +1,6 @@
1
1
  module TorqueboxCache
2
- VERSION = '3.0.0'
3
- MAVEN_VERSION = '3.0.0'
2
+ VERSION = '3.0.1'
3
+ MAVEN_VERSION = '3.0.1'
4
4
  end
5
5
  begin
6
6
  require 'java'
@@ -36,6 +36,7 @@ module TorqueBox
36
36
  end
37
37
  end
38
38
 
39
+ # @api public
39
40
  class Cache
40
41
 
41
42
  SECONDS = java.util.concurrent.TimeUnit::SECONDS
@@ -53,11 +54,14 @@ module TorqueBox
53
54
  end
54
55
 
55
56
  def initialize(opts = {})
56
- return nothing unless INFINISPAN_AVAILABLE
57
57
  @options = opts
58
- options[:transaction_mode] = :transactional unless options.has_key?( :transaction_mode )
59
- options[:locking_mode] ||= :optimistic if (transactional? && !options.has_key?( :locking_mode ))
60
- options[:sync] = true if options[:sync].nil?
58
+
59
+ if INFINISPAN_AVAILABLE
60
+ options[:transaction_mode] = :transactional unless options.has_key?( :transaction_mode )
61
+ options[:locking_mode] ||= :optimistic if (transactional? && !options.has_key?( :locking_mode ))
62
+ options[:sync] = true if options[:sync].nil?
63
+ end
64
+
61
65
  if options[:encoding] == :marshal
62
66
  log( "Encoding of :marshal cannot be used with " +
63
67
  "TorqueBox::Infinispan::Cache - using :marshal_base64 instead",
@@ -312,7 +316,9 @@ module TorqueBox
312
316
  config.transaction.lockingMode( locking_mode )
313
317
  end
314
318
  if persisted?
315
- store = config.loaders.add_file_cache_store
319
+ store = (config.respond_to?(:loaders) ?
320
+ config.loaders.add_file_cache_store :
321
+ config.persistence.add_single_file_store)
316
322
  store.purgeOnStartup( false )
317
323
  store.location(options[:persist]) if File.exist?( options[:persist].to_s )
318
324
  end
@@ -325,7 +331,7 @@ module TorqueBox
325
331
  config.build
326
332
  end
327
333
 
328
- def same_config?(c1, c2)
334
+ def same_5_config?(c1, c2)
329
335
  c1.clustering.cacheMode == c2.clustering.cacheMode &&
330
336
  (c1.loaders == c2.loaders ||
331
337
  (c1.loaders.cacheLoaders.size == c2.loaders.cacheLoaders.size &&
@@ -336,6 +342,25 @@ module TorqueBox
336
342
  c1.eviction.strategy == c2.eviction.strategy
337
343
  end
338
344
 
345
+ def same_6_config?(c1, c2)
346
+ c1.clustering.cacheMode == c2.clustering.cacheMode &&
347
+ (c1.persistence == c2.persistence ||
348
+ (c1.persistence.stores.size == c2.persistence.stores.size &&
349
+ c1.persistence.stores.first.location == c2.persistence.stores.first.location)) &&
350
+ c1.transaction.transactionMode == c2.transaction.transactionMode &&
351
+ c1.transaction.lockingMode == c2.transaction.lockingMode &&
352
+ c1.eviction.max_entries == c2.eviction.max_entries &&
353
+ c1.eviction.strategy == c2.eviction.strategy
354
+ end
355
+
356
+ def same_config?(c1, c2)
357
+ if c1.respond_to?(:loaders)
358
+ same_5_config?(c1, c2)
359
+ else
360
+ same_6_config?(c1, c2)
361
+ end
362
+ end
363
+
339
364
  def transaction_manager_lookup
340
365
  @tm ||= if TorqueBox.fetch('transaction-manager')
341
366
  ContainerTransactionManagerLookup.new
data/spec/cache_spec.rb CHANGED
@@ -283,20 +283,25 @@ describe TorqueBox::Infinispan::Cache do
283
283
  end
284
284
 
285
285
  describe "with persistence" do
286
+
287
+ def cache_on_disk(dir=nil, name=nil)
288
+ five = org.infinispan.Version::VERSION[/^5/]
289
+ File.join(File.dirname(__FILE__), '..',
290
+ (dir || (five ? 'Infinispan-FileCacheStore' : 'Infinispan-SingleFileStore')),
291
+ (name ? (five ? name : name+".dat") : ""))
292
+ end
293
+
286
294
  before(:all) do
287
- @default_dir = File.join(File.dirname(__FILE__), '..', 'Infinispan-FileCacheStore')
288
- @configured_dir = File.join( File.dirname(__FILE__), '..', random_string + "-persisted.cache" )
289
- @date_cfg_dir = File.join( File.dirname(__FILE__), '..', random_string + "-persisted-date.cache" )
290
- @index_dir = File.join( File.dirname(__FILE__), '..', 'java.util.HashMap' )
291
- FileUtils.mkdir @configured_dir
292
- FileUtils.mkdir @date_cfg_dir
295
+ @configured_dir = random_string + "-persisted.cache"
296
+ @date_cfg_dir = random_string + "-persisted-date.cache"
297
+ FileUtils.mkdir cache_on_disk(@configured_dir)
298
+ FileUtils.mkdir cache_on_disk(@date_cfg_dir)
293
299
  end
294
300
 
295
301
  after(:all) do
296
- FileUtils.rm_rf @default_dir
297
- FileUtils.rm_rf @configured_dir
298
- FileUtils.rm_rf @date_cfg_dir
299
- FileUtils.rm_rf @index_dir if File.exist?( @index_dir )
302
+ FileUtils.rm_rf cache_on_disk
303
+ FileUtils.rm_rf cache_on_disk(@configured_dir)
304
+ FileUtils.rm_rf cache_on_disk(@date_cfg_dir)
300
305
  end
301
306
 
302
307
  it "should persist the data with a default directory" do
@@ -304,22 +309,22 @@ describe TorqueBox::Infinispan::Cache do
304
309
  entry = java.util.HashMap.new
305
310
  entry.put( "Hello", "world" )
306
311
  cache.put('foo', entry)
307
- File.exist?(@default_dir).should be_true
312
+ File.exist?(cache_on_disk(nil, 'persisted-cache')).should be_true
308
313
  end
309
314
 
310
315
  it "should persist the data with a configured directory" do
311
- cache = TorqueBox::Infinispan::Cache.new( :name => 'persisted-date-cache', :persist => @configured_dir.to_s )
316
+ cache = TorqueBox::Infinispan::Cache.new( :name => 'persisted-date-cache', :persist => cache_on_disk(@configured_dir).to_s )
312
317
  entry = java.util.HashMap.new
313
318
  entry.put( "Hello", "world" )
314
319
  cache.put('foo', entry)
315
- File.exist?("#{@configured_dir.to_s}/persisted-date-cache").should be_true
320
+ File.exist?(cache_on_disk(@configured_dir, "persisted-date-cache")).should be_true
316
321
  end
317
322
 
318
323
  it "should persist dates with a configured directory" do
319
- cache = TorqueBox::Infinispan::Cache.new( :name => 'persisted-configured-date-cache', :persist => @date_cfg_dir.to_s )
324
+ cache = TorqueBox::Infinispan::Cache.new( :name => 'persisted-configured-date-cache', :persist => cache_on_disk(@date_cfg_dir).to_s )
320
325
  entry = java.util.Date.new
321
326
  cache.put('foo', entry).should be_nil
322
- File.exist?("#{@date_cfg_dir.to_s}/persisted-configured-date-cache").should be_true
327
+ File.exist?(cache_on_disk(@date_cfg_dir, "persisted-configured-date-cache")).should be_true
323
328
  end
324
329
 
325
330
  it "should evict keys from the heap" do
metadata CHANGED
@@ -1,15 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: torquebox-cache
3
3
  version: !ruby/object:Gem::Version
4
- prerelease:
5
- version: 3.0.0
4
+ version: 3.0.1
6
5
  platform: java
7
6
  authors:
8
7
  - The TorqueBox Team
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-08-28 00:00:00.000000000 Z
11
+ date: 2013-11-22 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: activesupport
@@ -18,13 +17,11 @@ dependencies:
18
17
  - - '='
19
18
  - !ruby/object:Gem::Version
20
19
  version: 3.0.10
21
- none: false
22
20
  requirement: !ruby/object:Gem::Requirement
23
21
  requirements:
24
22
  - - '='
25
23
  - !ruby/object:Gem::Version
26
24
  version: 3.0.10
27
- none: false
28
25
  prerelease: false
29
26
  type: :development
30
27
  - !ruby/object:Gem::Dependency
@@ -34,13 +31,11 @@ dependencies:
34
31
  - - '='
35
32
  - !ruby/object:Gem::Version
36
33
  version: 0.5.0
37
- none: false
38
34
  requirement: !ruby/object:Gem::Requirement
39
35
  requirements:
40
36
  - - '='
41
37
  - !ruby/object:Gem::Version
42
38
  version: 0.5.0
43
- none: false
44
39
  prerelease: false
45
40
  type: :development
46
41
  - !ruby/object:Gem::Dependency
@@ -49,14 +44,12 @@ dependencies:
49
44
  requirements:
50
45
  - - '='
51
46
  - !ruby/object:Gem::Version
52
- version: 3.0.0
53
- none: false
47
+ version: 3.0.1
54
48
  requirement: !ruby/object:Gem::Requirement
55
49
  requirements:
56
50
  - - '='
57
51
  - !ruby/object:Gem::Version
58
- version: 3.0.0
59
- none: false
52
+ version: 3.0.1
60
53
  prerelease: false
61
54
  type: :runtime
62
55
  - !ruby/object:Gem::Dependency
@@ -65,14 +58,12 @@ dependencies:
65
58
  requirements:
66
59
  - - '='
67
60
  - !ruby/object:Gem::Version
68
- version: 3.0.0
69
- none: false
61
+ version: 3.0.1
70
62
  requirement: !ruby/object:Gem::Requirement
71
63
  requirements:
72
64
  - - '='
73
65
  - !ruby/object:Gem::Version
74
- version: 3.0.0
75
- none: false
66
+ version: 3.0.1
76
67
  prerelease: false
77
68
  type: :runtime
78
69
  - !ruby/object:Gem::Dependency
@@ -82,13 +73,11 @@ dependencies:
82
73
  - - '='
83
74
  - !ruby/object:Gem::Version
84
75
  version: 1.4.6
85
- none: false
86
76
  requirement: !ruby/object:Gem::Requirement
87
77
  requirements:
88
78
  - - '='
89
79
  - !ruby/object:Gem::Version
90
80
  version: 1.4.6
91
- none: false
92
81
  prerelease: false
93
82
  type: :development
94
83
  - !ruby/object:Gem::Dependency
@@ -98,13 +87,11 @@ dependencies:
98
87
  - - '='
99
88
  - !ruby/object:Gem::Version
100
89
  version: 2.7.0
101
- none: false
102
90
  requirement: !ruby/object:Gem::Requirement
103
91
  requirements:
104
92
  - - '='
105
93
  - !ruby/object:Gem::Version
106
94
  version: 2.7.0
107
- none: false
108
95
  prerelease: false
109
96
  type: :development
110
97
  description: ''
@@ -122,14 +109,15 @@ files:
122
109
  - lib/torquebox/cache.rb
123
110
  - lib/active_support/cache/torquebox_store.rb
124
111
  - lib/active_support/cache/torque_box_store.rb
125
- - spec/spec.opts
126
- - spec/spec_helper.rb
127
- - spec/torque_box_store_spec.rb
128
112
  - spec/gem_hook_spec.rb
129
113
  - spec/cache_spec.rb
114
+ - spec/spec_helper.rb
115
+ - spec/torque_box_store_spec.rb
116
+ - spec/spec.opts
130
117
  homepage: http://torquebox.org/
131
118
  licenses:
132
119
  - Public Domain
120
+ metadata: {}
133
121
  post_install_message:
134
122
  rdoc_options: []
135
123
  require_paths:
@@ -139,20 +127,18 @@ required_ruby_version: !ruby/object:Gem::Requirement
139
127
  - - '>='
140
128
  - !ruby/object:Gem::Version
141
129
  version: '0'
142
- none: false
143
130
  required_rubygems_version: !ruby/object:Gem::Requirement
144
131
  requirements:
145
132
  - - '>='
146
133
  - !ruby/object:Gem::Version
147
134
  version: '0'
148
- none: false
149
135
  requirements: []
150
136
  rubyforge_project:
151
- rubygems_version: 1.8.24
137
+ rubygems_version: 2.1.9
152
138
  signing_key:
153
- specification_version: 3
139
+ specification_version: 4
154
140
  summary: TorqueBox Cache Gem
155
141
  test_files:
156
- - spec/torque_box_store_spec.rb
157
142
  - spec/gem_hook_spec.rb
158
143
  - spec/cache_spec.rb
144
+ - spec/torque_box_store_spec.rb