jruby-ehcache-rails3 1.1.2 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
data/bin/ehcache
CHANGED
File without changes
|
@@ -1,19 +1,18 @@
|
|
1
|
-
require 'ehcache/
|
1
|
+
require 'ehcache/active_support_store'
|
2
|
+
|
3
|
+
# Rails 3 cache store implementation which stores data in Ehcache:
|
4
|
+
# http://www.ehcache.org/
|
2
5
|
|
3
6
|
module ActiveSupport
|
4
7
|
module Cache
|
5
|
-
|
6
|
-
# Rails 3 cache store implementation which stores data in Ehcache:
|
7
|
-
# http://www.ehcache.org/
|
8
|
-
class EhcacheStore < Store
|
9
|
-
include Ehcache::Rails
|
8
|
+
class EhcacheStore < Ehcache::ActiveSupportStore
|
10
9
|
|
11
10
|
def initialize(*args)
|
12
11
|
args = args.flatten
|
13
12
|
options = args.extract_options!
|
14
13
|
super(options)
|
15
14
|
self.create_cache_manager(options)
|
16
|
-
@ehcache = self.create_cache(options)
|
15
|
+
@ehcache = self.create_cache(options)
|
17
16
|
extend Strategy::LocalCache
|
18
17
|
end
|
19
18
|
|
@@ -0,0 +1,59 @@
|
|
1
|
+
require 'ehcache/active_support_store'
|
2
|
+
|
3
|
+
# Rails 2 cache store implementation which stores data in Ehcache:
|
4
|
+
# http://www.ehcache.org/
|
5
|
+
|
6
|
+
module ActiveSupport
|
7
|
+
module Cache
|
8
|
+
class EhcacheStore < Ehcache::ActiveSupportStore
|
9
|
+
|
10
|
+
def initialize(options = {})
|
11
|
+
super() # Rails 2.3.x Store doesn't take any arguments to initialize
|
12
|
+
@ehcache = self.create_cache
|
13
|
+
end
|
14
|
+
|
15
|
+
def read(key, options = nil)
|
16
|
+
@ehcache[key]
|
17
|
+
rescue Ehcache::EhcacheError => e
|
18
|
+
logger.error("EhcacheError (#{e}): #{e.message}")
|
19
|
+
false
|
20
|
+
end
|
21
|
+
|
22
|
+
def write(key, value, options = {})
|
23
|
+
@ehcache.put(key, value, options)
|
24
|
+
true
|
25
|
+
rescue Ehcache::EhcacheError => e
|
26
|
+
logger.error("EhcacheError (#{e}): #{e.message}")
|
27
|
+
false
|
28
|
+
end
|
29
|
+
|
30
|
+
def delete(key, options = nil)
|
31
|
+
@ehcache.remove(key)
|
32
|
+
rescue Exception => e
|
33
|
+
logger.error("EhcacheError (#{e}): #{e.message}")
|
34
|
+
false
|
35
|
+
end
|
36
|
+
|
37
|
+
def keys
|
38
|
+
@ehcache.keys
|
39
|
+
end
|
40
|
+
|
41
|
+
def exist?(key, options = nil)
|
42
|
+
@ehcache.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
|
+
@ehcache.clear
|
52
|
+
true
|
53
|
+
rescue Exception => e
|
54
|
+
logger.error("EhcacheError (#{e}): #{e.message}")
|
55
|
+
false
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
# Common code used in the ehcache_store implementations for ActiveSupport 2.x and 3.x
|
2
|
+
require 'active_support'
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'ehcache'
|
6
|
+
rescue LoadError => e
|
7
|
+
$stderr.puts "You don't have ehcache installed in your application."
|
8
|
+
$stderr.puts "Please add it to your Gemfile and run bundle install"
|
9
|
+
raise e
|
10
|
+
end
|
11
|
+
|
12
|
+
# Base class for both the ActiveSupport 2 & 3 implementations
|
13
|
+
module Ehcache
|
14
|
+
class ActiveSupportStore < ActiveSupport::Cache::Store
|
15
|
+
|
16
|
+
cattr_accessor :config_directory
|
17
|
+
cattr_accessor :default_cache_name
|
18
|
+
|
19
|
+
attr_reader :cache_manager
|
20
|
+
|
21
|
+
def create_cache_manager(options = {})
|
22
|
+
config_dir = self.class.config_directory
|
23
|
+
config = if options[:ehcache_config]
|
24
|
+
File.expand_path(File.join(config_dir, options[:ehcache_config]))
|
25
|
+
else
|
26
|
+
Ehcache::Config::Configuration.find(config_dir) if config_dir
|
27
|
+
end
|
28
|
+
# Ehcache will use the failsafe configuration if nothing is passed in
|
29
|
+
# Note: .create is a factory method
|
30
|
+
@cache_manager = Ehcache::CacheManager.create(config)
|
31
|
+
end
|
32
|
+
|
33
|
+
def create_cache(options = {})
|
34
|
+
create_cache_manager(options) if @cache_manager.nil?
|
35
|
+
@cache_manager.cache(options[:cache_name] || default_cache_name)
|
36
|
+
end
|
37
|
+
|
38
|
+
def default_cache_name
|
39
|
+
self.class.default_cache_name || 'app_cache'
|
40
|
+
end
|
41
|
+
|
42
|
+
at_exit do
|
43
|
+
@cache_manager.shutdown if @cache_manager
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
47
|
+
end
|
metadata
CHANGED
@@ -1,93 +1,159 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: jruby-ehcache-rails3
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
|
6
|
-
- 1
|
7
|
-
- 1
|
8
|
-
- 2
|
9
|
-
prerelease: false
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease:
|
5
|
+
version: 1.2.0
|
10
6
|
platform: ruby
|
11
|
-
authors:
|
12
|
-
- Dylan Stamat
|
13
|
-
- Jason Voegele
|
14
|
-
autorequire:
|
7
|
+
authors:
|
8
|
+
- Dylan Stamat
|
9
|
+
- Jason Voegele
|
10
|
+
autorequire:
|
15
11
|
bindir: bin
|
16
12
|
cert_chain: []
|
17
|
-
|
18
|
-
|
19
|
-
dependencies:
|
20
|
-
- !ruby/object:Gem::Dependency
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
13
|
+
|
14
|
+
date: 2012-03-14 00:00:00 Z
|
15
|
+
dependencies:
|
16
|
+
- !ruby/object:Gem::Dependency
|
17
|
+
name: jruby-ehcache
|
18
|
+
version_requirements: &id001 !ruby/object:Gem::Requirement
|
19
|
+
none: false
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 1.2.0
|
24
|
+
requirement: *id001
|
25
|
+
prerelease: false
|
26
|
+
type: :runtime
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: jruby-ehcache
|
29
|
+
version_requirements: &id002 !ruby/object:Gem::Requirement
|
30
|
+
none: false
|
31
|
+
requirements:
|
32
|
+
- - ">="
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: "0"
|
35
|
+
requirement: *id002
|
36
|
+
prerelease: false
|
37
|
+
type: :runtime
|
38
|
+
- !ruby/object:Gem::Dependency
|
39
|
+
name: rake
|
40
|
+
version_requirements: &id003 !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ">="
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: "0"
|
46
|
+
requirement: *id003
|
47
|
+
prerelease: false
|
48
|
+
type: :development
|
49
|
+
- !ruby/object:Gem::Dependency
|
50
|
+
name: jeweler
|
51
|
+
version_requirements: &id004 !ruby/object:Gem::Requirement
|
52
|
+
none: false
|
53
|
+
requirements:
|
54
|
+
- - ">="
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
version: "0"
|
57
|
+
requirement: *id004
|
58
|
+
prerelease: false
|
59
|
+
type: :development
|
60
|
+
- !ruby/object:Gem::Dependency
|
61
|
+
name: rake
|
62
|
+
version_requirements: &id005 !ruby/object:Gem::Requirement
|
63
|
+
none: false
|
64
|
+
requirements:
|
65
|
+
- - ">="
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: "0"
|
68
|
+
requirement: *id005
|
69
|
+
prerelease: false
|
70
|
+
type: :development
|
71
|
+
- !ruby/object:Gem::Dependency
|
72
|
+
name: jeweler
|
73
|
+
version_requirements: &id006 !ruby/object:Gem::Requirement
|
74
|
+
none: false
|
75
|
+
requirements:
|
76
|
+
- - ">="
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
version: "0"
|
79
|
+
requirement: *id006
|
80
|
+
prerelease: false
|
81
|
+
type: :development
|
82
|
+
- !ruby/object:Gem::Dependency
|
83
|
+
name: rake
|
84
|
+
version_requirements: &id007 !ruby/object:Gem::Requirement
|
85
|
+
none: false
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: "0"
|
90
|
+
requirement: *id007
|
91
|
+
prerelease: false
|
92
|
+
type: :development
|
93
|
+
- !ruby/object:Gem::Dependency
|
94
|
+
name: jeweler
|
95
|
+
version_requirements: &id008 !ruby/object:Gem::Requirement
|
96
|
+
none: false
|
97
|
+
requirements:
|
98
|
+
- - ">="
|
99
|
+
- !ruby/object:Gem::Version
|
100
|
+
version: "0"
|
101
|
+
requirement: *id008
|
102
|
+
prerelease: false
|
103
|
+
type: :development
|
104
|
+
- !ruby/object:Gem::Dependency
|
105
|
+
name: jruby-ehcache
|
106
|
+
version_requirements: &id009 !ruby/object:Gem::Requirement
|
107
|
+
none: false
|
108
|
+
requirements:
|
109
|
+
- - ">="
|
110
|
+
- !ruby/object:Gem::Version
|
111
|
+
version: 1.2.0
|
112
|
+
requirement: *id009
|
113
|
+
prerelease: false
|
114
|
+
type: :runtime
|
50
115
|
description: Rails 3 cache store provider using Ehcache
|
51
|
-
email:
|
52
|
-
- dstamat@elctech.com
|
53
|
-
- jvoegele@terracotta.org
|
54
|
-
executables:
|
55
|
-
- ehcache
|
116
|
+
email:
|
117
|
+
- dstamat@elctech.com
|
118
|
+
- jvoegele@terracotta.org
|
119
|
+
executables:
|
120
|
+
- ehcache
|
56
121
|
extensions: []
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
- lib/
|
62
|
-
-
|
63
|
-
-
|
64
|
-
|
122
|
+
|
123
|
+
extra_rdoc_files:
|
124
|
+
- README.txt
|
125
|
+
files:
|
126
|
+
- lib/active_support/cache/ehcache_store.rb
|
127
|
+
- lib/active_support/ehcache_store.rb
|
128
|
+
- lib/ehcache/active_support_store.rb
|
129
|
+
- README.txt
|
130
|
+
- bin/ehcache
|
65
131
|
homepage: http://ehcache.rubyforge.org
|
66
132
|
licenses: []
|
67
|
-
|
133
|
+
|
134
|
+
post_install_message:
|
68
135
|
rdoc_options: []
|
69
|
-
|
70
|
-
|
71
|
-
|
136
|
+
|
137
|
+
require_paths:
|
138
|
+
- lib
|
139
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
72
140
|
none: false
|
73
|
-
requirements:
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
- 0
|
79
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
141
|
+
requirements:
|
142
|
+
- - ">="
|
143
|
+
- !ruby/object:Gem::Version
|
144
|
+
version: "0"
|
145
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
80
146
|
none: false
|
81
|
-
requirements:
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
segments:
|
86
|
-
- 0
|
147
|
+
requirements:
|
148
|
+
- - ">="
|
149
|
+
- !ruby/object:Gem::Version
|
150
|
+
version: "0"
|
87
151
|
requirements: []
|
152
|
+
|
88
153
|
rubyforge_project: ehcache
|
89
|
-
rubygems_version: 1.
|
90
|
-
signing_key:
|
154
|
+
rubygems_version: 1.8.9
|
155
|
+
signing_key:
|
91
156
|
specification_version: 3
|
92
157
|
summary: Rails 3 cache store provider using Ehcache
|
93
158
|
test_files: []
|
159
|
+
|
@@ -1,42 +0,0 @@
|
|
1
|
-
begin
|
2
|
-
require 'ehcache'
|
3
|
-
rescue LoadError => e
|
4
|
-
$stderr.puts "You don't have ehcache installed in your application."
|
5
|
-
$stderr.puts "Please add it to your Gemfile and run bundle install"
|
6
|
-
raise e
|
7
|
-
end
|
8
|
-
|
9
|
-
module Ehcache
|
10
|
-
# Mixin module providing facilities for the Rails 2 and Rails 3 Cache::Store
|
11
|
-
# implementations.
|
12
|
-
module Rails
|
13
|
-
|
14
|
-
RAILS_CONFIG_DIR = File.join(RAILS_ROOT, 'config')
|
15
|
-
|
16
|
-
DEFAULT_RAILS_CACHE_NAME = 'rails_cache'
|
17
|
-
|
18
|
-
attr_reader :cache_manager
|
19
|
-
|
20
|
-
def create_cache_manager(options)
|
21
|
-
config = nil
|
22
|
-
if options[:ehcache_config]
|
23
|
-
Dir.chdir(RAILS_CONFIG_DIR) do
|
24
|
-
config = File.expand_path(options[:ehcache_config])
|
25
|
-
end
|
26
|
-
else
|
27
|
-
config = Ehcache::Config::Configuration.find(RAILS_CONFIG_DIR)
|
28
|
-
end
|
29
|
-
@cache_manager = Ehcache::CacheManager.create(config)
|
30
|
-
end
|
31
|
-
|
32
|
-
def create_cache(options)
|
33
|
-
create_cache_manager(options) if @cache_manager.nil?
|
34
|
-
|
35
|
-
@cache = @cache_manager.cache(options[:cache_name] || DEFAULT_RAILS_CACHE_NAME)
|
36
|
-
end
|
37
|
-
|
38
|
-
at_exit do
|
39
|
-
@cache_manager.shutdown if @cache_manager
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|