factorylabs-cache-money 0.2.5 → 0.2.6

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.
Files changed (2) hide show
  1. data/rails/init.rb +22 -0
  2. metadata +2 -1
data/rails/init.rb ADDED
@@ -0,0 +1,22 @@
1
+ require 'cache_money'
2
+
3
+ memcache_config = YAML.load_file(File.join(Rails.root,'config','memcached.yml'))
4
+
5
+ memcache_options = memcache_config['defaults'].merge(memcache_config[Rails.env])
6
+
7
+ unless memcache_options['disabled'] || Rails.env.test?
8
+ $memcache = MemCache.new(memcache_options)
9
+ $memcache.servers = memcache_options['servers']
10
+ else
11
+ $memcache = Cash::Mock.new
12
+ end
13
+
14
+ ActionController::Base.session_options[:cache] = $memcache if memcache_options['sessions']
15
+
16
+ $local = Cash::Local.new($memcache)
17
+ $lock = Cash::Lock.new($memcache)
18
+ $cache = Cash::Transactional.new($local, $lock)
19
+
20
+ class ActiveRecord::Base
21
+ is_cached :repository => $cache
22
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: factorylabs-cache-money
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.5
4
+ version: 0.2.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nick Kallen
@@ -71,6 +71,7 @@ files:
71
71
  - lib/cash/util/array.rb
72
72
  - lib/cash/write_through.rb
73
73
  - lib/cache_money.rb
74
+ - rails/init.rb
74
75
  has_rdoc: false
75
76
  homepage: http://github.com/nkallen/cache-money
76
77
  post_install_message: