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.425 lib/lalala/cache.rb
lalala-4.1.0.dev.420 lib/lalala/cache.rb
lalala-4.1.0.dev.419 lib/lalala/cache.rb
lalala-4.1.0.dev.418 lib/lalala/cache.rb
lalala-4.1.0.dev.417 lib/lalala/cache.rb
lalala-4.0.0.dev.416 lib/lalala/cache.rb
lalala-4.1.0.dev.415 lib/lalala/cache.rb
lalala-4.1.0.dev.414 lib/lalala/cache.rb
lalala-4.1.0.dev.413 lib/lalala/cache.rb
lalala-4.1.0.dev.412 lib/lalala/cache.rb
lalala-4.1.0.dev.411 lib/lalala/cache.rb
lalala-4.1.0.dev.410 lib/lalala/cache.rb
lalala-4.1.0.dev.409 lib/lalala/cache.rb
lalala-4.0.0.dev.407 lib/lalala/cache.rb
lalala-4.1.0.dev.408 lib/lalala/cache.rb
lalala-4.1.0.dev.398 lib/lalala/cache.rb
lalala-4.1.0.dev.397 lib/lalala/cache.rb
lalala-4.0.0.dev.396 lib/lalala/cache.rb
lalala-4.0.0.dev.395 lib/lalala/cache.rb
lalala-4.1.0.dev.394 lib/lalala/cache.rb