Padrino Commit Oct 15, 2013
ujifgc Merge pull request #1018 from minad/moneta-replace
#1018のマージコミットです。
minad replace Padrino::Cache::Store with Moneta
Padrino::Cache のコア実装が moneta にリプレースされました。
これにより、キャッシュ・ストアの指定方法が後方互換のない変更となっているので注意が必要です。
アプリケーション内で使用する場合の例として、これまで
# set :cache, Padrino::Cache::Store::Memcache.new(::Memcached.new('127.0.0.1:11211', :exception_retry_limit => 1)) # set :cache, Padrino::Cache::Store::Memcache.new(::Dalli::Client.new('127.0.0.1:11211', :exception_retry_limit => 1)) # set :cache, Padrino::Cache::Store::Redis.new(::Redis.new(:host => '127.0.0.1', :port => 6379, :db => 0)) # set :cache, Padrino::Cache::Store::Memory.new(50) set :cache, Padrino::Cache::Store::File.new(Padrino.root('tmp', app_name, 'cache') MyApp.cache.set('val', 'test', :expires_in => 30) MyApp.cache.get('val') # => 'test' MyApp.cache.delete('val') MyApp.cache.flush
としていたのが
# set :cache, Padrino::Cache.new(:Memcached, :server => '127.0.0.1:11211', :exception_retry_limit => 1) # set :cache, Padrino::Cache.new(:MemcachedDalli, :server => '127.0.0.1:11211', :exception_retry_limit => 1) # set :cache, Padrino::Cache.new(:Redis, :host => '127.0.0.1', :port => 6379, :db => 0) # set :cache, Padrino::Cache.new(:LRUHash, :maxsize => 50) set :cache, Padrino::Cache.new(:File, :dir => Padrino.root('tmp', app_name.to_s, 'cache')) MyApp.cache.store('val', 'test', :expires => 30) # expires を指定しない場合は MyApp.cache['val'] = 'test' MyApp.cache['val'] # => 'test' MyApp.cache.delete('val') MyApp.cache.clear
となります。
expires_in オプションと set, get, flush メソッドは引き続き使用できますが WARN が出力されます。