Sha256: 2fe53853b19867af59ad78d32164f3e3d560c0f7229ad6ff1f540ce3bc47475e

Contents?: true

Size: 994 Bytes

Versions: 1

Compression:

Stored size: 994 Bytes

Contents

# CacheCow

CacheCow allows ActiveRecord models to `acts_as_cached``


## Install

In your Gemfile

    gem "cache_cow"

Or via command line

    gem install cache_cow


## Overview

CacheCow provides an api for caching results of methods and associations on ActiveRecord models.

To use in a model, declare `acts_as_cached`

``` ruby

    class Post
      acts_as_cached
    end

```

Instances of a cache_cow model can read, write, fetch, and expire their own cache keys. Cache keys
are namespaced and versioned by convention as <class_name>:<version>:<id>:<cache_suffix>. An instances
id is the cache suffix be default.

``` ruby

    # Post.cache_cow_version = 1

    post = Post.find(123)

    post.fetch_cache { "great post" }     # fetches from cache key 'Post:1:123', store 'great post' on cache miss

    post.write_cache("foo", "bar")        # writes 'bar to cache key 'Post:1:123:foo'

    post.read_cache("foo")                # returns 'bar' from cache key 'Post:1:123:foo'

````

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
cache_cow-0.0.1 README.md