activesupport-jcache 0.1.0

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.
data/History.txt ADDED
@@ -0,0 +1,5 @@
1
+ === 0.1.0 / 2009-05-28
2
+
3
+ * Initial release
4
+ * Support for basic operations
5
+ * No support for key expiry
data/Manifest.txt ADDED
@@ -0,0 +1,6 @@
1
+ History.txt
2
+ Manifest.txt
3
+ README.txt
4
+ Rakefile
5
+ lib/jcache_store.rb
6
+ lib/active_support/cache/jcache_store.rb
data/README.txt ADDED
@@ -0,0 +1,56 @@
1
+ = activesupport-jcache
2
+
3
+ == DESCRIPTION:
4
+
5
+ ActiveSupport-JCache is a jRuby on Rails extension that enables JCache backend store for Rails.cache
6
+
7
+ == FEATURES/PROBLEMS:
8
+
9
+ * No support for time-based key expiry
10
+
11
+ == REQUIREMENTS:
12
+
13
+ * ActiveSupport 2.3.2
14
+ * JCache-enabled store
15
+
16
+ == INSTALL:
17
+
18
+ * sudo gem install activesupport-jcache
19
+
20
+ == CONFIGURATION:
21
+
22
+ In your config/environment.rb, add the following:
23
+
24
+ if defined?(JRUBY_VERSION)
25
+ config.gem "activesupport-jcache", :lib => 'jcache_store'
26
+ config.cache_store = :jcache_store
27
+ end
28
+
29
+ == GOOGLE APP ENGINE:
30
+
31
+ ActiveSupport-JCache allows to interface with the MemCache API within the Google App Engine. No additional configuration required.
32
+
33
+ == LICENSE:
34
+
35
+ (The MIT License)
36
+
37
+ Copyright (c) 2009 Michael Rykov
38
+
39
+ Permission is hereby granted, free of charge, to any person obtaining
40
+ a copy of this software and associated documentation files (the
41
+ 'Software'), to deal in the Software without restriction, including
42
+ without limitation the rights to use, copy, modify, merge, publish,
43
+ distribute, sublicense, and/or sell copies of the Software, and to
44
+ permit persons to whom the Software is furnished to do so, subject to
45
+ the following conditions:
46
+
47
+ The above copyright notice and this permission notice shall be
48
+ included in all copies or substantial portions of the Software.
49
+
50
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
51
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
52
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
53
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
54
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
55
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
56
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Rakefile ADDED
@@ -0,0 +1,14 @@
1
+ # -*- ruby -*-
2
+
3
+ require 'rubygems'
4
+ require 'hoe'
5
+ require './lib/jcache_store.rb'
6
+
7
+ Hoe.new('activesupport-jcache', ActiveSupport::Cache::JcacheStore::VERSION) do |p|
8
+ p.rubyforge_name = 'am-javamail'
9
+ p.developer('Michael Rykov', 'michael@missingfeature.com')
10
+ p.url = 'http://github.com/rykov/activesupport-jcache'
11
+ p.blog_categories = ['activesupport-jcache', 'activesupport', 'jcache', 'cache', 'jruby', 'rails', 'ruby', 'java']
12
+ end
13
+
14
+ # vim: syntax=Ruby
@@ -0,0 +1,65 @@
1
+ require 'activesupport'
2
+
3
+ module ActiveSupport
4
+ module Cache
5
+ class JcacheStore < Store
6
+ VERSION = '0.1.0'
7
+ include_class "java.util.Collections"
8
+ include_class "javax.cache.CacheException"
9
+ include_class "javax.cache.CacheManager"
10
+
11
+ class JcacheError < StandardError; end
12
+
13
+ def initialize(options = {})
14
+ cacheFactory = CacheManager.get_instance.get_cache_factory;
15
+ @data = cacheFactory.create_cache(Collections.empty_map);
16
+ end
17
+
18
+ def read(key, options = nil)
19
+ super
20
+ @data.get(key)
21
+ rescue CacheException => e
22
+ logger.error("JcacheError (#{e}): #{e.message}")
23
+ false
24
+ end
25
+
26
+ def write(key, value, options = {})
27
+ super
28
+ @data.put(key, value)
29
+ true
30
+ rescue CacheException => e
31
+ logger.error("JcacheError (#{e}): #{e.message}")
32
+ false
33
+ end
34
+
35
+ def delete(key, options = nil)
36
+ super
37
+ @data.remove(key)
38
+ rescue CacheException => e
39
+ logger.error("JcacheError (#{e}): #{e.message}")
40
+ false
41
+ end
42
+
43
+ def keys
44
+ @data.key_set.to_a
45
+ end
46
+
47
+ def exist?(key, options = nil)
48
+ @data.contains_key(key)
49
+ end
50
+
51
+ def delete_matched(matcher, options = nil)
52
+ super
53
+ raise "Not supported by Ehcache"
54
+ end
55
+
56
+ def clear
57
+ @data.clear
58
+ true
59
+ rescue CacheException => e
60
+ logger.error("JcacheError (#{e}): #{e.message}")
61
+ false
62
+ end
63
+ end
64
+ end
65
+ end
@@ -0,0 +1,37 @@
1
+ #--
2
+ # Copyright (c) 2009 Michael Rykov
3
+ #
4
+ # Permission is hereby granted, free of charge, to any person obtaining
5
+ # a copy of this software and associated documentation files (the
6
+ # "Software"), to deal in the Software without restriction, including
7
+ # without limitation the rights to use, copy, modify, merge, publish,
8
+ # distribute, sublicense, and/or sell copies of the Software, and to
9
+ # permit persons to whom the Software is furnished to do so, subject to
10
+ # the following conditions:
11
+ #
12
+ # The above copyright notice and this permission notice shall be
13
+ # included in all copies or substantial portions of the Software.
14
+ #
15
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19
+ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20
+ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21
+ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
+ #++
23
+
24
+ $:.unshift(File.dirname(__FILE__)) unless $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
25
+
26
+ if defined?(JRUBY_VERSION) && defined?(javax.cache)
27
+ require 'java'
28
+ require 'active_support/cache/jcache_store'
29
+ end
30
+
31
+ module ActiveSupport
32
+ module Cache
33
+ class JcacheStore
34
+ VERSION = '0.1.0'
35
+ end
36
+ end
37
+ end
metadata ADDED
@@ -0,0 +1,75 @@
1
+ --- !ruby/object:Gem::Specification
2
+ extensions: []
3
+
4
+ homepage: http://github.com/rykov/activesupport-jcache
5
+ executables: []
6
+
7
+ version: !ruby/object:Gem::Version
8
+ version: 0.1.0
9
+ post_install_message:
10
+ date: 2009-05-29 07:00:00 +00:00
11
+ files:
12
+ - History.txt
13
+ - Manifest.txt
14
+ - README.txt
15
+ - Rakefile
16
+ - lib/jcache_store.rb
17
+ - lib/active_support/cache/jcache_store.rb
18
+ rubygems_version: 1.3.3
19
+ rdoc_options:
20
+ - --main
21
+ - README.txt
22
+ signing_key:
23
+ cert_chain: []
24
+
25
+ name: activesupport-jcache
26
+ has_rdoc: true
27
+ platform: ruby
28
+ summary: ActiveSupport-JCache is a jRuby on Rails extension that enables JCache backend
29
+ store for Rails.cache
30
+ default_executable:
31
+ bindir: bin
32
+ licenses: []
33
+
34
+ required_rubygems_version: !ruby/object:Gem::Requirement
35
+ version:
36
+ requirements:
37
+ - - '>='
38
+ - !ruby/object:Gem::Version
39
+ version: "0"
40
+ required_ruby_version: !ruby/object:Gem::Requirement
41
+ version:
42
+ requirements:
43
+ - - '>='
44
+ - !ruby/object:Gem::Version
45
+ version: "0"
46
+ require_paths:
47
+ - lib
48
+ specification_version: 3
49
+ test_files: []
50
+
51
+ dependencies:
52
+ - !ruby/object:Gem::Dependency
53
+ type: :development
54
+ name: hoe
55
+ version_requirement:
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ version:
58
+ requirements:
59
+ - - '>='
60
+ - !ruby/object:Gem::Version
61
+ version: 1.12.2
62
+ description: ActiveSupport-JCache is a jRuby on Rails extension that enables JCache
63
+ backend store for Rails.cache
64
+ email:
65
+ - michael@missingfeature.com
66
+ authors:
67
+ - Michael Rykov
68
+ extra_rdoc_files:
69
+ - History.txt
70
+ - Manifest.txt
71
+ - README.txt
72
+ requirements: []
73
+
74
+ rubyforge_project: am-javamail
75
+ autorequire: