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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c4aa749a4640d7ca3fe3729890999c3c51fe0bd1b273cde488367410c9496acf
4
- data.tar.gz: a117fcaef9eaa8b354b3d047585d43af8e0261c4bddf66c903f735cfa2ec9f44
3
+ metadata.gz: 201b3f3dad3c0cc9a9e768e08811efdf32d332f1d1e0e88e6d72271244d26def
4
+ data.tar.gz: c7173944b2f31198acc1b191f80d9ab556df979b5afa756527673b189413781b
5
5
  SHA512:
6
- metadata.gz: ba317a626c14dda2d79925cee3757ce47ead9ec88a5ecb1bfff034c65e72be0619f232d552d79f1d819cf0ce1900c716e957faaa0ef3141c78273e5b53b1fd8d
7
- data.tar.gz: ec9cca1b5820d6e03ab90d8d0903f44494c50c193c79d95d6aebf66cf79d34e284d9ee56dd16452f8d57ff23cb1eb8950ef695ab577d1723d639391be1ba838e
6
+ metadata.gz: e992720b1e3c154069e710e15673fd73ebdc0f7b5f63aa79f17a97ec28c58b84fa024ff04997dbce4e8eac3df2409cc051c257254cf9e2743a4433637b001a33
7
+ data.tar.gz: 3e96bb5f875de6fca09406447d921fb59b34880341d427fdc81e72448a8176d25b1a9bfd503a05c56413903db5808cddc27678bf06c6d68dd8137b1b11a48b56
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
- ## [Unreleased]
1
+ ## [Released]
2
2
 
3
3
  ## [0.1.0] - 2024-11-21
4
4
 
5
5
  - Initial release
6
+
7
+ ## [0.1.2] - 2024-12-02
8
+
9
+ - Improved documentation in the README, added Table of Contents and more code examples
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
@@ -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."
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Builder
4
4
  module RailsCache
5
- VERSION = "0.1.1"
5
+ VERSION = "0.1.2"
6
6
  end
7
7
  end
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.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-30 00:00:00.000000000 Z
11
+ date: 2024-12-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails