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.1.5 lib/cuboid/support/cache/preference.rb
cuboid-0.1.4 lib/cuboid/support/cache/preference.rb
cuboid-0.1.3 lib/cuboid/support/cache/preference.rb
cuboid-0.1.2 lib/cuboid/support/cache/preference.rb
cuboid-0.1.1 lib/cuboid/support/cache/preference.rb
cuboid-0.1.0 lib/cuboid/support/cache/preference.rb
cuboid-0.0.5 lib/cuboid/support/cache/preference.rb
cuboid-0.0.4 lib/cuboid/support/cache/preference.rb
cuboid-0.0.3 lib/cuboid/support/cache/preference.rb
cuboid-0.0.3alpha lib/cuboid/support/cache/preference.rb
cuboid-0.0.2alpha lib/cuboid/support/cache/preference.rb
cuboid-0.0.1alpha lib/cuboid/support/cache/preference.rb