Sha256: d74ac2166ca7e8cc0c30f9ca091ffac4f52a22dfa4b0eb0f6e23149cc009d77e

Contents?: true

Size: 489 Bytes

Versions: 32

Compression:

Stored size: 489 Bytes

Contents

module Cuboid
module Support::Cache

# @author Tasos "Zapotek" Laskos <tasos.laskos@gmail.com>
class Preference < Base

    def prefer( &block )
        @preference = block
    end

    private

    def store_with_internal_key( k, v )
        prune if capped? && (size > max_size - 1)

        _store( k, v )
    end

    def find_preference
        @preference.call
    end

    def prune
        preferred = find_preference
        delete( preferred ) if preferred
    end

end

end
end

Version data entries

32 entries across 32 versions & 1 rubygems

Version Path
cuboid-0.2.11 lib/cuboid/support/cache/preference.rb
cuboid-0.2.10 lib/cuboid/support/cache/preference.rb
cuboid-0.2.9 lib/cuboid/support/cache/preference.rb
cuboid-0.2.8 lib/cuboid/support/cache/preference.rb
cuboid-0.2.7 lib/cuboid/support/cache/preference.rb
cuboid-0.2.6 lib/cuboid/support/cache/preference.rb
cuboid-0.2.5 lib/cuboid/support/cache/preference.rb
cuboid-0.2.4.2 lib/cuboid/support/cache/preference.rb
cuboid-0.2.4.1 lib/cuboid/support/cache/preference.rb
cuboid-0.2.4 lib/cuboid/support/cache/preference.rb
cuboid-0.2.3 lib/cuboid/support/cache/preference.rb
cuboid-0.2.2 lib/cuboid/support/cache/preference.rb
cuboid-0.2.1 lib/cuboid/support/cache/preference.rb
cuboid-0.2 lib/cuboid/support/cache/preference.rb
cuboid-0.1.9.1 lib/cuboid/support/cache/preference.rb
cuboid-0.1.9 lib/cuboid/support/cache/preference.rb
cuboid-0.1.8 lib/cuboid/support/cache/preference.rb
cuboid-0.1.7 lib/cuboid/support/cache/preference.rb
cuboid-0.1.6.1 lib/cuboid/support/cache/preference.rb
cuboid-0.1.6 lib/cuboid/support/cache/preference.rb