README.md in catch_cache-0.1.0 vs README.md in catch_cache-0.2.0
- old
+ new
@@ -18,10 +18,12 @@
$ gem install catch_cache
## Usage
+### To cache objects
+
```ruby
class ServiceWithAVerySlowQuery
include CatchCache::Cache
def query
@@ -32,10 +34,11 @@
end
end
end
```
+### :flush_cache!
In your AR model:
```ruby
class LoanApplication < ActiveRecord::Base
include CatchCache::Flush
@@ -44,10 +47,10 @@
# Everytime the :after_commit AR callback is called,
# the Redis cache with id "lead_timeline_logs_#{lead.id}"
# is going to be flushed
- cache_id :lead_timeline_logs, after_commit: -> { lead.id }
+ cache_id :lead_timeline_logs, after_commit: -> { flush_cache!: -> { lead.id } }
end
```
### :flush_all!
Use `:flush_all` to clear the cache for all the keys with the suffix defined in `cache_id`