factorylabs-cache-money 0.2.7 → 0.2.8
Sign up to get free protection for your applications and to get access to all the features.
- data/rails/init.rb +15 -0
- metadata +1 -1
data/rails/init.rb
CHANGED
@@ -1,5 +1,18 @@
|
|
1
1
|
require 'cache_money'
|
2
2
|
|
3
|
+
module ::ActiveSupport
|
4
|
+
module Cache
|
5
|
+
class CacheMoneyMemCacheStore < MemCacheStore
|
6
|
+
|
7
|
+
def initialize
|
8
|
+
@addresses = $memcache.servers
|
9
|
+
@data = $memcache
|
10
|
+
end
|
11
|
+
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
3
16
|
memcache_config = YAML.load_file(File.join(Rails.root,'config','memcached.yml'))
|
4
17
|
|
5
18
|
memcache_options = memcache_config['defaults'].merge(memcache_config[Rails.env])
|
@@ -11,7 +24,9 @@ else
|
|
11
24
|
$memcache = Cash::Mock.new
|
12
25
|
end
|
13
26
|
|
27
|
+
ActionController::Base.cache_store = :cache_money_mem_cache_store
|
14
28
|
ActionController::Base.session_options[:cache] = $memcache if memcache_options['sessions']
|
29
|
+
silence_warnings { Object.const_set "RAILS_CACHE", ActiveSupport::Cache.lookup_store(:cache_money_mem_cache_store) }
|
15
30
|
|
16
31
|
$local = Cash::Local.new($memcache)
|
17
32
|
$lock = Cash::Lock.new($memcache)
|