Sha256: a70e4a9351837e0f7c8ea671a1f2169f4b0ce25a6f7127800097a6f78ddf9662

Contents?: true

Size: 1.33 KB

Versions: 24

Compression:

Stored size: 1.33 KB

Contents

# BlockCache

by Matthew Scharley
http://github.com/mscharley/ruby-blockcache

## Overview

> In computer science, a cache is a component that improves performance 
> by transparently storing data such that future requests for that 
> data can be served faster.
>
> -- [Cache at Wikipedia](http://en.wikipedia.org/wiki/Cache)

Typical caches do this by allowing you to store data in them, along with
a time limit to describe how long this data is valid for. You then need
to check if the data is available, and if not, regenerate it and store
it again, ready for next time.

BlockCache eliminates all this. You define your cache, describe the
elements it contains, and then you never have to worry about making
sure you have fresh data again. Of course, if you need to ensure that
you are getting clean, uncached data, you can do that too.

## Example Usage

    require 'blockcache'
    
    cache = BlockCache.new
    cache.add('name', 10) do
      puts "Hello, what is your name?"
      STDIN.gets.strip
    end
    
    for i in [1,2]
      for j in [1,3]
        puts "Hello " + cache['name'] + "!"
      end
      cache.refresh
    end

In the example above, you get asked for your name, then it says 
hello to you three times. Note, each time is using the exact same
code. The program then tells the cache that it wants fresh data,
and repeats the process.

Version data entries

24 entries across 24 versions & 2 rubygems

Version Path
redcar-dev-0.12.1dev-java plugins/scm/vendor/ruby-blockcache/README.md
redcar-dev-0.12.0dev-java plugins/scm/vendor/ruby-blockcache/README.md
redcar-0.11 plugins/scm/vendor/ruby-blockcache/README.md
redcar-0.11.0dev plugins/scm/vendor/ruby-blockcache/README.md
redcar-0.10 plugins/scm/vendor/ruby-blockcache/README.md
redcar-0.9.2 plugins/scm/vendor/ruby-blockcache/README.md
redcar-0.9.1 plugins/scm/vendor/ruby-blockcache/README.md
redcar-0.9.0 plugins/scm/vendor/ruby-blockcache/README.md
redcar-0.8.1 plugins/scm/vendor/ruby-blockcache/README.md
redcar-0.8 plugins/scm/vendor/ruby-blockcache/README.md
redcar-0.7 plugins/scm/vendor/ruby-blockcache/README.md
redcar-0.6.1 plugins/scm/vendor/ruby-blockcache/README.md
redcar-0.6 plugins/scm/vendor/ruby-blockcache/README.md
redcar-0.6.1dev plugins/scm/vendor/ruby-blockcache/README.md
redcar-0.5.1 plugins/scm/vendor/ruby-blockcache/README.md
redcar-0.5 plugins/scm/vendor/ruby-blockcache/README.md
redcar-0.5.6dev plugins/scm/vendor/ruby-blockcache/README.md
redcar-0.5.5dev plugins/scm/vendor/ruby-blockcache/README.md
redcar-0.5.4dev plugins/scm/vendor/ruby-blockcache/README.md
redcar-0.5.3dev plugins/scm/vendor/ruby-blockcache/README.md