Sha256: e3415b557c291748116b120ce165eb597aeb7c056f6023c2f31036eb8afd61c2

Contents?: true

Size: 977 Bytes

Versions: 3

Compression:

Stored size: 977 Bytes

Contents

module CanTango
  class Ability
    class Cache
      class SessionCache < BaseCache
        attr_accessor :session
        attr_reader   :key

        # will be called with :session => session (pointing to user session)
        def initialize name, options = {}
          super # will set all instance vars using options hash
          @cache = cache
          @cache.configure_with :type => :memory
          raise "SessionCache must be initialized with a :session option" if !session
          session[cache_key] = @cache
        end

        def cache_key
          @cache_key ||= :rules_cache
        end

        def store
          session[cache_key]
        end

        def load key
          store.load! key
        end

        def save key, rules
          store.save! key, rules
        end

        def invalidate! key
          store.delete key
        end

        def cache
          CanTango::Cache::HashCache.instance
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
cantango-0.9.4.2 lib/cantango/ability/cache/session_cache.rb
cantango-0.9.4.1 lib/cantango/ability/cache/session_cache.rb
cantango-0.9.4 lib/cantango/ability/cache/session_cache.rb