Sha256: 2b6d70f8b684bea70874173951c8c2b07179d40a1f8016b575cb93a16b365885

Contents?: true

Size: 919 Bytes

Versions: 144

Compression:

Stored size: 919 Bytes

Contents

module Lalala::Cache

  def self.setup!(app, servers, username, password)
    if servers.blank?
      return
    end

    require 'dalli'

    app.config.cache_store = [
      :dalli_store,
      *servers,
      {
        :namespace  => "lalala",
        :expires_in => 1.day,
        :compress   => true,
        :username   => username,
        :password   => password
      }
    ]

    app.config.to_prepare do
      Lalala::Cache.flush!
    end

    ActiveRecord::Base.send(:include, Lalala::Cache::Flusher)
  end

  def self.flush!
    unless "ActiveSupport::Cache::DalliStore" === Rails.cache.class.to_s
      return
    end

    Rails.logger.info("memcache: Flushing all entries")
    Rails.cache.clear
  end

  module Flusher
    extend ActiveSupport::Concern

    included do
      after_commit :lalala_flush_cache
    end

  private

    def lalala_flush_cache
      Lalala::Cache.flush!
    end

  end

end

Version data entries

144 entries across 144 versions & 1 rubygems

Version Path
lalala-4.1.0.dev.359 lib/lalala/cache.rb
lalala-4.1.0.dev.358 lib/lalala/cache.rb
lalala-4.0.0.dev.357 lib/lalala/cache.rb
lalala-4.1.0.dev.356 lib/lalala/cache.rb
lalala-4.1.0.dev.355 lib/lalala/cache.rb
lalala-4.0.0.dev.354 lib/lalala/cache.rb
lalala-4.0.0.dev.351 lib/lalala/cache.rb
lalala-4.0.0.dev.350 lib/lalala/cache.rb
lalala-4.0.0.dev.349 lib/lalala/cache.rb
lalala-4.0.0.dev.344 lib/lalala/cache.rb
lalala-4.0.0.dev.343 lib/lalala/cache.rb
lalala-4.1.0.dev.342 lib/lalala/cache.rb
lalala-4.1.0.dev.341 lib/lalala/cache.rb
lalala-4.1.0.dev.340 lib/lalala/cache.rb
lalala-4.0.0.dev.339 lib/lalala/cache.rb
lalala-4.0.0.dev.336 lib/lalala/cache.rb
lalala-4.1.0.dev.334 lib/lalala/cache.rb
lalala-4.1.0.dev.332 lib/lalala/cache.rb
lalala-4.0.0.dev.331 lib/lalala/cache.rb
lalala-4.0.0.dev.329 lib/lalala/cache.rb