jruby-ehcache-rails2 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. data/README.txt +84 -0
  2. data/bin/ehcache +28 -0
  3. data/lib/ehcache_store.rb +59 -0
  4. metadata +83 -0
data/README.txt ADDED
@@ -0,0 +1,84 @@
1
+ = Ehcache for JRuby
2
+
3
+ http://github.com/dylanz/ehcache
4
+
5
+ == DESCRIPTION:
6
+
7
+ Ehcache is a simplified JRuby interface to Java's (JSR-107 compliant) Ehcache.
8
+ Simplified meaning that it should work out-of-the-box, but a lot of native
9
+ methods haven't been interfaced yet, as they weren't needed. Configuration
10
+ occurs in config/ehcache.yml, and should support all the configuration
11
+ options available.
12
+
13
+ Some biased and non-biased Ehcache VS Memcache articles:
14
+ http://gregluck.com/blog/archives/2007/05/comparing_memca.html
15
+ http://feedblog.org/2007/05/21/unfair-benchmarks-of-ehcache-vs-memcached
16
+ http://blog.aristotlesdog.com/2008/05/01/memcached_vs_ehcache/
17
+ http://www.hugotroche.com/my_weblog/2008/06/ehcache-vs-memc.html
18
+
19
+ For more information on Ehcache, see:
20
+ http://www.ehcache.org/
21
+
22
+ Configuration, Code Samples and everything else, see:
23
+ http://ehcache.org/documentation/index.html
24
+
25
+ Google Groups:
26
+ http://groups.google.com/group/ehcache-jruby
27
+
28
+ Tickets:
29
+ http://dylanz.lighthouseapp.com/projects/14518-ehcache-jruby/overview
30
+
31
+
32
+ == BASIC USAGE:
33
+
34
+ manager = CacheManager.new
35
+ cache = manager.cache
36
+ cache.put("key", "value", {:ttl => 120})
37
+ cache.get("key")
38
+ manager.shutdown
39
+
40
+
41
+ == RAILS:
42
+
43
+ Rails 2 and Rails 3 integration are provided by the separate ehcache-rails2
44
+ and ehcache-rails3 gems. To install, choose the correct version for your
45
+ Rails application and use JRuby's gem command to install, e.g.:
46
+
47
+ $ jgem install ehcache-rails3
48
+ OR
49
+ $ jruby -S gem install ehcache-rails3
50
+
51
+
52
+ == REQUIREMENTS:
53
+
54
+ Tested with JRuby 1.5.0.
55
+
56
+
57
+ == INSTALL:
58
+
59
+ $ sudo jruby -S gem install ehcache
60
+
61
+
62
+ == LICENSE:
63
+ Copyright (c) 2008 Dylan Stamat <dstamat@elctech.com>
64
+
65
+ Permission is hereby granted, free of charge, to any person
66
+ obtaining a copy of this software and associated documentation
67
+ files (the "Software"), to deal in the Software without
68
+ restriction, including without limitation the rights to use,
69
+ copy, modify, merge, publish, distribute, sublicense, and/or sell
70
+ copies of the Software, and to permit persons to whom the
71
+ Software is furnished to do so, subject to the following
72
+ conditions:
73
+
74
+ The above copyright notice and this permission notice shall be
75
+ included in all copies or substantial portions of the Software.
76
+
77
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
78
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
79
+ OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
80
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
81
+ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
82
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
83
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
84
+ OTHER DEALINGS IN THE SOFTWARE.
data/bin/ehcache ADDED
@@ -0,0 +1,28 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'rake'
4
+ require 'rubygems'
5
+ require 'ehcache'
6
+
7
+ # TODO: optionparser this up once anything else is added
8
+ if $*.pop == "rails"
9
+ unless File.exists?("config/boot.rb")
10
+ abort "Oops... make sure you are running this from your RAILS_ROOT"
11
+ end
12
+
13
+ # copy default ehcache.yml into config/
14
+ if File.exists?("config/ehcache.yml")
15
+ warn "It looks like ehcache.yml already exists in config/"
16
+ else
17
+ FileUtils.cp("#{Ehcache::EHCACHE_HOME}/config/ehcache.yml", "config/")
18
+ end
19
+
20
+ # add ehcache store
21
+ if File.exists?("lib/ehcache_store.rb")
22
+ warn "It looks like ehcache_store.rb already exists in lib/"
23
+ else
24
+ FileUtils.cp("#{Ehcache::EHCACHE_HOME}/ext/rails/ehcache_store.rb", "lib/")
25
+ end
26
+ else
27
+ warn "Usage: specify 'rails' as an argument to install required files"
28
+ end
@@ -0,0 +1,59 @@
1
+ require 'activesupport'
2
+ require 'ehcache'
3
+
4
+ module ActiveSupport
5
+ module Cache
6
+ class EhcacheStore < Store
7
+ def initialize(options = {})
8
+ manager = Ehcache::CacheManager.new(options)
9
+ @data = manager.cache
10
+ end
11
+
12
+ def read(key, options = nil)
13
+ super
14
+ @data.get(key)
15
+ rescue Ehcache::EhcacheError => e
16
+ logger.error("EhcacheError (#{e}): #{e.message}")
17
+ false
18
+ end
19
+
20
+ def write(key, value, options = nil)
21
+ super
22
+ @data.set(key, value, options)
23
+ true
24
+ rescue Ehcache::EhcacheError => e
25
+ logger.error("EhcacheError (#{e}): #{e.message}")
26
+ false
27
+ end
28
+
29
+ def delete(key, options = nil)
30
+ super
31
+ @data.delete(key)
32
+ rescue Exception => e
33
+ logger.error("EhcacheError (#{e}): #{e.message}")
34
+ false
35
+ end
36
+
37
+ def keys
38
+ @data.keys
39
+ end
40
+
41
+ def exist?(key, options = nil)
42
+ @data.exist?(key)
43
+ end
44
+
45
+ def delete_matched(matcher, options = nil)
46
+ super
47
+ raise "Not supported by Ehcache"
48
+ end
49
+
50
+ def clear
51
+ @data.clear
52
+ true
53
+ rescue Exception => e
54
+ logger.error("EhcacheError (#{e}): #{e.message}")
55
+ false
56
+ end
57
+ end
58
+ end
59
+ end
metadata ADDED
@@ -0,0 +1,83 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: jruby-ehcache-rails2
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 5
8
+ - 0
9
+ version: 0.5.0
10
+ platform: ruby
11
+ authors:
12
+ - Dylan Stamat
13
+ - Jason Voegele
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2010-09-24 00:00:00 -04:00
19
+ default_executable: ehcache
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ name: jruby-ehcache
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ segments:
30
+ - 0
31
+ - 5
32
+ - 0
33
+ version: 0.5.0
34
+ type: :runtime
35
+ version_requirements: *id001
36
+ description: Rails 2 cache store provider using Ehcache
37
+ email:
38
+ - dstamat@elctech.com
39
+ - jvoegele@terracotta.org
40
+ executables:
41
+ - ehcache
42
+ extensions: []
43
+
44
+ extra_rdoc_files:
45
+ - README.txt
46
+ files:
47
+ - lib/ehcache_store.rb
48
+ - README.txt
49
+ - bin/ehcache
50
+ has_rdoc: true
51
+ homepage: http://ehcache.rubyforge.org
52
+ licenses: []
53
+
54
+ post_install_message:
55
+ rdoc_options:
56
+ - --charset=UTF-8
57
+ require_paths:
58
+ - lib
59
+ required_ruby_version: !ruby/object:Gem::Requirement
60
+ none: false
61
+ requirements:
62
+ - - ">="
63
+ - !ruby/object:Gem::Version
64
+ segments:
65
+ - 0
66
+ version: "0"
67
+ required_rubygems_version: !ruby/object:Gem::Requirement
68
+ none: false
69
+ requirements:
70
+ - - ">="
71
+ - !ruby/object:Gem::Version
72
+ segments:
73
+ - 0
74
+ version: "0"
75
+ requirements: []
76
+
77
+ rubyforge_project: ehcache
78
+ rubygems_version: 1.3.7
79
+ signing_key:
80
+ specification_version: 3
81
+ summary: Rails 2 cache store provider using Ehcache
82
+ test_files: []
83
+