Sha256: 82f4d095465dbe4d6158d7ffc23db648b62e339f911dfe15ef83470fb9f652ff
Contents?: true
Size: 1.35 KB
Versions: 3
Compression:
Stored size: 1.35 KB
Contents
require_relative 'cache' class CacheBuilder # @param [Cache] cache Initializes with the type of Cache to be used def initialize(cache) @cache = cache.new end # @param [Cache] cache Sets the type of Cache to be used def self.with(cache) return self.new(cache) end # Sets the required file path for the FileCache # @param [String] path The path of the directory where cached files should be stored def set_store(path) @cache.store = path return self end # @param [String] time The time value after which an object should expire in the cache. Can be written as '2s' for two seconds, for example. For more info see: https://github.com/jmettraux/rufus-scheduler/blob/two/README.rdoc#the-time-strings-understood-by-rufus-scheduler def set_expiry(time) @cache.expiry_time = time return self end # Sets the refresh method required for recalling new objects after expiration # @param [Proc] proc The refresh method as a Proc object def set_refresh(proc) @cache.refresh = proc return self end # Sets the optional max size of a cache # @param [Integer] max_size The max size of the cache def set_max(max_size) @cache.max_size = max_size return self end # Returns the newly created cache def build @cache.create_store return @cache.dup end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
libcache-0.4.1 | lib/libcache/cache_builder.rb |
libcache-0.4 | lib/libcache/cache_builder.rb |
libcache-0.3 | lib/libcache/cache_builder.rb |