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.324 lib/lalala/cache.rb
lalala-4.1.0.dev.322 lib/lalala/cache.rb
lalala-4.1.0.dev.321 lib/lalala/cache.rb
lalala-4.1.0.dev.318 lib/lalala/cache.rb
lalala-4.1.0.dev.316 lib/lalala/cache.rb
lalala-4.1.0.dev.314 lib/lalala/cache.rb
lalala-4.0.0.dev.313 lib/lalala/cache.rb
lalala-4.1.0.dev.309 lib/lalala/cache.rb
lalala-4.1.0.dev.305 lib/lalala/cache.rb
lalala-4.1.0.dev.299 lib/lalala/cache.rb
lalala-4.0.0.dev.291 lib/lalala/cache.rb
lalala-4.0.0.dev.288 lib/lalala/cache.rb
lalala-4.0.0.dev.285 lib/lalala/cache.rb
lalala-4.0.0.dev.284 lib/lalala/cache.rb
lalala-4.0.0.dev.283 lib/lalala/cache.rb
lalala-4.0.0.dev.279 lib/lalala/cache.rb
lalala-4.0.0.dev.277 lib/lalala/cache.rb
lalala-4.0.0.dev.275 lib/lalala/cache.rb
lalala-4.0.0.dev.269 lib/lalala/cache.rb
lalala-4.0.0.dev.267 lib/lalala/cache.rb