builder-rails_cache 0.1.1 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -1
- data/README.md +23 -3
- data/builder-rails_cache.gemspec +0 -2
- data/lib/builder/rails_cache/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 201b3f3dad3c0cc9a9e768e08811efdf32d332f1d1e0e88e6d72271244d26def
|
4
|
+
data.tar.gz: c7173944b2f31198acc1b191f80d9ab556df979b5afa756527673b189413781b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e992720b1e3c154069e710e15673fd73ebdc0f7b5f63aa79f17a97ec28c58b84fa024ff04997dbce4e8eac3df2409cc051c257254cf9e2743a4433637b001a33
|
7
|
+
data.tar.gz: 3e96bb5f875de6fca09406447d921fb59b34880341d427fdc81e72448a8176d25b1a9bfd503a05c56413903db5808cddc27678bf06c6d68dd8137b1b11a48b56
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -2,6 +2,11 @@
|
|
2
2
|
|
3
3
|
Provides a convenient `with_cache do ... end` wrapper around caching Rails responses, and shared_examples for use in your controller tests.
|
4
4
|
|
5
|
+
### Contents
|
6
|
+
[[_TOC_]]
|
7
|
+
|
8
|
+
### Example controller method:
|
9
|
+
|
5
10
|
```ruby
|
6
11
|
def index
|
7
12
|
# Cache the response across all users
|
@@ -21,6 +26,21 @@ Provides a convenient `with_cache do ... end` wrapper around caching Rails respo
|
|
21
26
|
end
|
22
27
|
```
|
23
28
|
|
29
|
+
Or to cache a different response for each user :
|
30
|
+
|
31
|
+
|
32
|
+
```ruby
|
33
|
+
def index
|
34
|
+
# Cache the response separately for each user:
|
35
|
+
json = with_cache(user_id: current_user.id) do
|
36
|
+
@records = MyModelClass.where(....)
|
37
|
+
@records.to_json
|
38
|
+
end
|
39
|
+
render json: json, status: :ok
|
40
|
+
end
|
41
|
+
```
|
42
|
+
|
43
|
+
|
24
44
|
## Installation
|
25
45
|
|
26
46
|
1. Add the gem to your Gemfile:
|
@@ -43,7 +63,7 @@ _NOTE: future versions will automate as much of the following steps as possible
|
|
43
63
|
|
44
64
|
(this can either be the global `BuilderBase::ApplicationController` or just for one specific module if you prefer):
|
45
65
|
|
46
|
-
```
|
66
|
+
```ruby
|
47
67
|
class ApplicationController < ActionController::Base
|
48
68
|
include Builder::RailsCache
|
49
69
|
end
|
@@ -118,7 +138,7 @@ Add these lines to `config/environment/production.rb`, anywhere _inside_ the `Ra
|
|
118
138
|
|
119
139
|
For example, assume your controller method looks like this:
|
120
140
|
|
121
|
-
```
|
141
|
+
```ruby
|
122
142
|
def index
|
123
143
|
# Slow query:
|
124
144
|
@records = MyModelClass.where(....)
|
@@ -205,7 +225,7 @@ The contents of the block are not called at all if there's a cache hit - so you
|
|
205
225
|
|
206
226
|
For example, this code -
|
207
227
|
|
208
|
-
```
|
228
|
+
```ruby
|
209
229
|
def show
|
210
230
|
@record = MyClass.find(params[:id])
|
211
231
|
render json: @record.to_json, status: :ok
|
data/builder-rails_cache.gemspec
CHANGED
@@ -13,8 +13,6 @@ Gem::Specification.new do |spec|
|
|
13
13
|
spec.homepage = "https://gitlab.builder.ai/cte/alistair-davidson/builder-rails_cache"
|
14
14
|
spec.required_ruby_version = ">= 2.6.0"
|
15
15
|
|
16
|
-
# spec.metadata["allowed_push_host"] = "https://gem.fury.io/engineerai"
|
17
|
-
|
18
16
|
spec.metadata["homepage_uri"] = spec.homepage
|
19
17
|
spec.metadata["source_code_uri"] = spec.homepage
|
20
18
|
# spec.metadata["changelog_uri"] = "TODO: Put your gem's CHANGELOG.md URL here."
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: builder-rails_cache
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alistair Davidson
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-12-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|