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.392 lib/lalala/cache.rb
lalala-4.0.0.dev.393 lib/lalala/cache.rb
lalala-4.1.0.dev.391 lib/lalala/cache.rb
lalala-4.1.0.dev.390 lib/lalala/cache.rb
lalala-4.1.0.dev.389 lib/lalala/cache.rb
lalala-4.0.0.dev.388 lib/lalala/cache.rb
lalala-4.1.0.dev.387 lib/lalala/cache.rb
lalala-4.1.0.dev.386 lib/lalala/cache.rb
lalala-4.0.0.dev.385 lib/lalala/cache.rb
lalala-4.1.0.dev.384 lib/lalala/cache.rb
lalala-4.0.0.dev.382 lib/lalala/cache.rb
lalala-4.1.0.dev.381 lib/lalala/cache.rb
lalala-4.1.0.dev.376 lib/lalala/cache.rb
lalala-4.1.0.dev.375 lib/lalala/cache.rb
lalala-4.0.0.dev.374 lib/lalala/cache.rb
lalala-4.0.0.dev.372 lib/lalala/cache.rb
lalala-4.0.0.dev.368 lib/lalala/cache.rb
lalala-4.1.0.dev.367 lib/lalala/cache.rb
lalala-4.0.0.dev.366 lib/lalala/cache.rb
lalala-4.1.0.dev.360 lib/lalala/cache.rb