activerecord-cached_at 5.1.0 → 6.1.0
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 +5 -5
- data/README.md +89 -6
- data/ext/active_record/connection_adapters/abstract/schema_definitions.rb +8 -6
- data/ext/active_record/connection_adapters/abstract/schema_statements.rb +28 -5
- data/lib/cached_at.rb +2 -2
- data/lib/cached_at/associations/association.rb +1 -1
- data/lib/cached_at/associations/belongs_to_association.rb +2 -2
- data/lib/cached_at/associations/collection_association.rb +6 -4
- data/lib/cached_at/associations/has_many_through_association.rb +3 -3
- data/lib/cached_at/associations/has_one_association.rb +1 -1
- data/lib/cached_at/base.rb +29 -7
- data/lib/cached_at/helpers.rb +31 -7
- data/lib/cached_at/timestamp.rb +4 -2
- data/lib/cached_at/version.rb +1 -1
- metadata +10 -13
- data/lib/cached_at/connection_adapters/abstract/schema_definitions.rb +0 -17
- data/lib/cached_at/connection_adapters/abstract/schema_statements.rb +0 -21
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 89f6c8c10ca1cb627c057112961cb80ff26440026b723b5cf4240e4873089604
|
4
|
+
data.tar.gz: 05374e1138987e67d9a0fb5866278f1d495168799859ccb8cc77e4bc8dc8b724
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2053953fe7212f64ee1d03ed6956f409f25ae3c53666c25acd7224ecefa3e8ed0b1d2daf99317087d7c7fed0ea846a10eceec4de9776c31c530f31bc518b54ab
|
7
|
+
data.tar.gz: fbeed1272d1d6a5961733ec128516a5b1dc9f093061775c24ba1c14c30bf28f8730436542d8ca45de738a41d957332fd5daf133d74d54c37b9f6f9db137c7eff
|
data/README.md
CHANGED
@@ -1,15 +1,16 @@
|
|
1
|
-
# ActiveRecord - CachedAt
|
1
|
+
# ActiveRecord - CachedAt [](https://travis-ci.org/malomalo/activerecord-cached_at)
|
2
2
|
|
3
3
|
This gem causes ActiveRecord to update a `cached_at` column if present, like the
|
4
4
|
`updated_at` column.
|
5
5
|
|
6
6
|
When calculating a `cache_key` for a model it will also consider the `cached_at`
|
7
|
-
column to
|
7
|
+
column to determine the key of a model.
|
8
8
|
|
9
9
|
Any `ActiveRecord::Migration` that calls `timestamps` will include a `cached_at`
|
10
10
|
column.
|
11
11
|
|
12
|
-
|
12
|
+
Call to [`ActiveRecord::Persistence::touch`](https://api.rubyonrails.org/classes/ActiveRecord/Persistence.html#method-i-touch)
|
13
|
+
will also touch the `cached_at` column.
|
13
14
|
|
14
15
|
## Installation
|
15
16
|
|
@@ -22,12 +23,94 @@ aren't updating the models you can just require the helpers:
|
|
22
23
|
|
23
24
|
gem 'activerecord-cached_at', require: 'cached_at/helpers'
|
24
25
|
|
26
|
+
## Configuration
|
25
27
|
|
28
|
+
By default updates to the `cached_at`, `updated_at`, and `created_at` columns
|
29
|
+
will not trigger and update to the `cached_at` column. You can add aditional
|
30
|
+
fields to ignore:
|
31
|
+
|
32
|
+
```ruby
|
33
|
+
class User
|
34
|
+
cached_at ignore: :my_column
|
35
|
+
end
|
36
|
+
|
37
|
+
class Photo
|
38
|
+
cached_at ignore: :column_a, :column_b
|
39
|
+
end
|
40
|
+
```
|
41
|
+
## Relationship Cache Keys
|
42
|
+
|
43
|
+
CachedAt also allows you to keep cache keys for relationships. This allows you
|
44
|
+
to use the record to determine if a cache is valid for a relationship instead
|
45
|
+
of doing another database query.
|
46
|
+
|
47
|
+
For example:
|
48
|
+
|
49
|
+
```ruby
|
50
|
+
class User < ActiveRecord::Base
|
51
|
+
has_many :photos
|
52
|
+
end
|
53
|
+
|
54
|
+
class Photo
|
55
|
+
belongs_to :user, cached_at: true
|
56
|
+
end
|
57
|
+
|
58
|
+
bob_ross = User.create(name: 'Bob Ross')
|
59
|
+
# => INSERT INTO "users"
|
60
|
+
# ("name", "cached_at", "updated_at_", "created_at")
|
61
|
+
# VALUES
|
62
|
+
# ("Bob Ross", "2020-07-19 20:22:03", "2020-07-19 20:22:03", "2020-07-19 20:22:03")
|
63
|
+
|
64
|
+
photo = Photo.create(user: bob_ross, file: ...)
|
65
|
+
# =>INSERT INTO "photos" ("user_id", "cached_at", "updated_at_", "created_at") VALUES (1, "Bob Ross", "2020-07-19 20:22:04", "2020-07-19 20:22:04", "2020-07-19 20:22:04")
|
66
|
+
# => UPDATE "users" SET "photos_cached_at" = "2020-07-19 20:22:04" WHERE "users"."id" = 1
|
67
|
+
|
68
|
+
photo.update(file: ...)
|
69
|
+
# =>UPDATE "photos" (..., "cached_at", "updated_at_") VALUES (..., "2020-07-19 20:22:05", "2020-07-19 20:22:05", "2020-07-19 20:22:05")
|
70
|
+
# => UPDATE "users" SET "photos_cached_at" = "2020-07-19 20:22:05" WHERE "users"."id" = 1
|
71
|
+
|
72
|
+
photo.update(user: not_bob_ross)
|
73
|
+
# =>UPDATE "photos" ("user_id", "cached_at", "updated_at_") VALUES (2, "2020-07-19 20:22:06", "2020-07-19 20:22:06", "2020-07-19 20:22:06")
|
74
|
+
# => UPDATE "users" SET "photos_cached_at" = "2020-07-19 20:22:06" WHERE "users"."id" IN (1, 2)
|
75
|
+
|
76
|
+
photo.destroy
|
77
|
+
# => UPDATE "users" SET "photos_cached_at" = "2020-07-19 20:22:07" WHERE "users"."id" = 2
|
78
|
+
# => DELETE FROM "users" WHERE WHERE "users"."id" = 2
|
79
|
+
```
|
80
|
+
|
81
|
+
# Usage
|
82
|
+
|
83
|
+
`cached_at` will automatically be used for determining the cache key in Rails.
|
84
|
+
|
85
|
+
However if you need to calculate the cache key based on relationship cache keys
|
86
|
+
you will need to manually compute the cache key. Examples are below:
|
87
|
+
|
88
|
+
The cache key here is the maxium of the following keys: `cached_at`,
|
89
|
+
`listings_cached_at`, and `photos_cached_at`
|
90
|
+
|
91
|
+
```erb
|
92
|
+
<%= render partial: 'row', collection: @properties, as: :property, cached: Proc.new { |item|
|
93
|
+
[item.cache_key_with_version(:listings, :photos), current_account.id ]
|
94
|
+
} %>
|
95
|
+
|
96
|
+
<% cache @property.cache_key_with_version(:listings, :photos) do %>
|
97
|
+
<b>All the info on this property</b>
|
98
|
+
<%= @property.name %>
|
99
|
+
<% @property.listings.each do |listing| %>
|
100
|
+
<%= listing.info %>
|
101
|
+
<% end %>
|
102
|
+
<% @property.photos.each do |photo| %>
|
103
|
+
<%= image_tag(photo.url) %>
|
104
|
+
<% end %>
|
105
|
+
<% end %>
|
106
|
+
|
107
|
+
```
|
26
108
|
## TODO:
|
27
109
|
|
28
|
-
|
110
|
+
* Document going more than one level with cached_at keys
|
29
111
|
|
112
|
+
* Add a `cache_key` method to the Model class that gets `MAX(cached_at)`
|
30
113
|
|
114
|
+
* change option to cache: true
|
31
115
|
|
32
|
-
|
33
|
-
add cache_association helper
|
116
|
+
* add cache_association helper
|
@@ -2,14 +2,16 @@ module ActiveRecord
|
|
2
2
|
module ConnectionAdapters #:nodoc:
|
3
3
|
|
4
4
|
class TableDefinition
|
5
|
-
def timestamps(
|
6
|
-
options = args.extract_options!
|
7
|
-
|
5
|
+
def timestamps(**options)
|
8
6
|
options[:null] = false if options[:null].nil?
|
9
7
|
|
10
|
-
|
11
|
-
|
12
|
-
|
8
|
+
if !options.key?(:precision) && @conn.supports_datetime_with_precision?
|
9
|
+
options[:precision] = 6
|
10
|
+
end
|
11
|
+
|
12
|
+
column(:created_at, :datetime, **options)
|
13
|
+
column(:updated_at, :datetime, **options)
|
14
|
+
column(:cached_at, :datetime, **options)
|
13
15
|
end
|
14
16
|
end
|
15
17
|
|
@@ -2,19 +2,42 @@ module ActiveRecord
|
|
2
2
|
module ConnectionAdapters #:nodoc:
|
3
3
|
|
4
4
|
module SchemaStatements
|
5
|
-
def add_timestamps(table_name, options
|
5
|
+
def add_timestamps(table_name, **options)
|
6
6
|
options[:null] = false if options[:null].nil?
|
7
7
|
|
8
|
-
|
9
|
-
|
10
|
-
|
8
|
+
if !options.key?(:precision) && supports_datetime_with_precision?
|
9
|
+
options[:precision] = 6
|
10
|
+
end
|
11
|
+
|
12
|
+
add_column table_name, :created_at, :datetime, **options
|
13
|
+
add_column table_name, :updated_at, :datetime, **options
|
14
|
+
add_column table_name, :cached_at, :datetime, **options
|
11
15
|
end
|
12
16
|
|
13
|
-
def remove_timestamps(table_name, options
|
17
|
+
def remove_timestamps(table_name, **options)
|
14
18
|
remove_column table_name, :updated_at
|
15
19
|
remove_column table_name, :created_at
|
16
20
|
remove_column table_name, :cached_at
|
17
21
|
end
|
22
|
+
|
23
|
+
def add_timestamps_for_alter(table_name, **options)
|
24
|
+
options[:null] = false if options[:null].nil?
|
25
|
+
|
26
|
+
if !options.key?(:precision) && supports_datetime_with_precision?
|
27
|
+
options[:precision] = 6
|
28
|
+
end
|
29
|
+
|
30
|
+
[
|
31
|
+
add_column_for_alter(table_name, :created_at, :datetime, **options),
|
32
|
+
add_column_for_alter(table_name, :updated_at, :datetime, **options),
|
33
|
+
add_column_for_alter(table_name, :cached_at, :datetime, **options)
|
34
|
+
]
|
35
|
+
end
|
36
|
+
|
37
|
+
def remove_timestamps_for_alter(table_name, **options)
|
38
|
+
remove_columns_for_alter(table_name, :updated_at, :created_at, :cached_at)
|
39
|
+
end
|
40
|
+
|
18
41
|
end
|
19
42
|
|
20
43
|
end
|
data/lib/cached_at.rb
CHANGED
@@ -3,5 +3,5 @@ require 'active_record'
|
|
3
3
|
require File.expand_path(File.join(__FILE__, '../cached_at/base'))
|
4
4
|
require File.expand_path(File.join(__FILE__, '../cached_at/helpers'))
|
5
5
|
require File.expand_path(File.join(__FILE__, '../cached_at/timestamp'))
|
6
|
-
require File.expand_path(File.join(__FILE__, '
|
7
|
-
require File.expand_path(File.join(__FILE__, '
|
6
|
+
require File.expand_path(File.join(__FILE__, '../../ext/active_record/connection_adapters/abstract/schema_definitions'))
|
7
|
+
require File.expand_path(File.join(__FILE__, '../../ext/active_record/connection_adapters/abstract/schema_statements'))
|
@@ -41,7 +41,7 @@ module CachedAt
|
|
41
41
|
|
42
42
|
source_assoc = owner.association(r.source_reflection_name.to_sym)
|
43
43
|
if source_assoc.loaded?
|
44
|
-
source_assoc.target.
|
44
|
+
source_assoc.target.send(:write_attribute_without_type_cast, cache_column, timestamp)
|
45
45
|
end
|
46
46
|
query = r.klass.where(r.association_primary_key => owner.send(r.foreign_key))
|
47
47
|
query.update_all({ cache_column => timestamp })
|
@@ -45,7 +45,7 @@ module CachedAt
|
|
45
45
|
end
|
46
46
|
|
47
47
|
if loaded? && target
|
48
|
-
target.
|
48
|
+
target.send(:write_attribute_without_type_cast, cache_column, timestamp)
|
49
49
|
end
|
50
50
|
end
|
51
51
|
|
@@ -54,7 +54,7 @@ module CachedAt
|
|
54
54
|
timestamp = Time.now
|
55
55
|
cache_column = "#{options[:inverse_of]}_cached_at"
|
56
56
|
if loaded? && target
|
57
|
-
target.
|
57
|
+
target.send(:write_attribute_without_type_cast, cache_column, timestamp)
|
58
58
|
end
|
59
59
|
end
|
60
60
|
|
@@ -12,9 +12,11 @@ module CachedAt
|
|
12
12
|
cache_column = "#{reflection.inverse_of.name}_cached_at"
|
13
13
|
ids = [owner.send(reflection.association_primary_key), owner.send("#{reflection.association_primary_key}_before_last_save")].compact.uniq
|
14
14
|
query = klass.where({ reflection.foreign_key => ids })
|
15
|
-
|
15
|
+
|
16
16
|
if loaded?
|
17
|
-
target.each
|
17
|
+
target.each do |record|
|
18
|
+
record.send(:write_attribute_without_type_cast, cache_column, timestamp)
|
19
|
+
end
|
18
20
|
end
|
19
21
|
|
20
22
|
if method != :destroy
|
@@ -40,14 +42,14 @@ module CachedAt
|
|
40
42
|
|
41
43
|
cache_column = "#{reflection.inverse_of.name}_cached_at"
|
42
44
|
|
43
|
-
records.each { |r| r.
|
45
|
+
records.each { |r| r.send(:write_attribute_without_type_cast, cache_column, timestamp) unless r.destroyed? }
|
44
46
|
|
45
47
|
query = klass.where({ klass.primary_key => records.map(&:id) })
|
46
48
|
query.update_all({ cache_column => timestamp })
|
47
49
|
traverse_relationships(klass, options[:cached_at], query, cache_column, timestamp)
|
48
50
|
end
|
49
51
|
|
50
|
-
def add_to_target(record, skip_callbacks
|
52
|
+
def add_to_target(record, skip_callbacks: false, replace: false, &block)
|
51
53
|
value = super
|
52
54
|
touch_records_cached_at([record], Time.now) if !(instance_variable_defined?(:@caching) && @caching)
|
53
55
|
value
|
@@ -15,7 +15,7 @@ module CachedAt
|
|
15
15
|
|
16
16
|
query = nil
|
17
17
|
if loaded?
|
18
|
-
target.each { |r| r.
|
18
|
+
target.each { |r| r.send(:write_attribute_without_type_cast, cache_column, timestamp) }
|
19
19
|
query = klass.where(klass.primary_key => target.map(&:id))
|
20
20
|
else
|
21
21
|
ids = [owner.send(using_reflection.association_primary_key), owner.send("#{using_reflection.association_primary_key}_before_last_save")].compact.uniq
|
@@ -35,7 +35,7 @@ module CachedAt
|
|
35
35
|
#TODO: test with new record (fails in mls)
|
36
36
|
if !owner.new_record? && using_reflection.inverse_of && using_reflection.inverse_of.options[:cached_at]
|
37
37
|
cache_column = "#{using_reflection.name}_cached_at"
|
38
|
-
owner.
|
38
|
+
owner.send(:write_attribute_without_type_cast, cache_column, timestamp)
|
39
39
|
owner.update_columns(cache_column => timestamp)
|
40
40
|
end
|
41
41
|
end
|
@@ -50,7 +50,7 @@ module CachedAt
|
|
50
50
|
end
|
51
51
|
|
52
52
|
cache_column = "#{using_reflection.inverse_of.name}_cached_at"
|
53
|
-
records.each { |r| r.
|
53
|
+
records.each { |r| r.send(:write_attribute_without_type_cast, cache_column, timestamp) }
|
54
54
|
query = klass.where(klass.primary_key => records.map(&:id))
|
55
55
|
query.update_all({ cache_column => timestamp })
|
56
56
|
traverse_relationships(klass, using_reflection.options[:cached_at], query, cache_column, timestamp)
|
data/lib/cached_at/base.rb
CHANGED
@@ -13,24 +13,38 @@ module CachedAt
|
|
13
13
|
extend ActiveSupport::Concern
|
14
14
|
|
15
15
|
included do
|
16
|
+
class_attribute :cached_at_settings, default: {ignore: ['cached_at', 'updated_at', 'created_at']}
|
17
|
+
before_save :set_cached_at
|
16
18
|
before_save :update_belongs_to_cached_at_keys
|
17
19
|
before_destroy { update_relations_cached_at(method: :destroy) }
|
18
20
|
|
19
21
|
after_touch { update_relations_cached_at_from_cached_at(method: :touch) }
|
20
|
-
after_save
|
22
|
+
after_save :update_relations_cached_at_from_cached_at
|
23
|
+
end
|
24
|
+
|
25
|
+
class_methods do
|
26
|
+
def cached_at(ignore: [])
|
27
|
+
ignore = [ignore] if !ignore.is_a?(Array)
|
28
|
+
self.cached_at_settings[:ignore].push(*ignore.map(&:to_s))
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def touch(*names, time: nil)
|
33
|
+
names.push('cached_at')
|
34
|
+
super(*names, time: time)
|
21
35
|
end
|
22
36
|
|
23
37
|
private
|
24
38
|
|
25
39
|
def update_relations_cached_at_from_cached_at(method: nil)
|
26
|
-
update_relations_cached_at(
|
40
|
+
update_relations_cached_at(
|
27
41
|
timestamp: (self.class.column_names.include?('cached_at') ? cached_at : nil),
|
28
42
|
method: method
|
29
|
-
|
43
|
+
)
|
30
44
|
end
|
31
45
|
|
32
46
|
def update_relations_cached_at(timestamp: nil, method: nil)
|
33
|
-
method =
|
47
|
+
method = @_new_record_before_last_commit ? :create : :update if method.nil?
|
34
48
|
|
35
49
|
diff = saved_changes.transform_values(&:first)
|
36
50
|
return if method == :create && diff.empty?
|
@@ -49,22 +63,30 @@ module CachedAt
|
|
49
63
|
end
|
50
64
|
end
|
51
65
|
|
66
|
+
def set_cached_at
|
67
|
+
return if !self.class.column_names.include?('cached_at')
|
68
|
+
diff = changes.transform_values(&:first)
|
69
|
+
return if diff.keys.all? { |k| cached_at_settings[:ignore].include?(k) }
|
70
|
+
|
71
|
+
self.cached_at = current_time_from_proper_timezone
|
72
|
+
end
|
73
|
+
|
52
74
|
def update_belongs_to_cached_at_keys
|
53
75
|
self.class.reflect_on_all_associations.each do |reflection|
|
54
76
|
next unless reflection.is_a?(ActiveRecord::Reflection::BelongsToReflection)
|
55
77
|
cache_column = "#{reflection.name}_cached_at"
|
56
78
|
|
57
79
|
if self.attribute_names.include?(cache_column)
|
58
|
-
if self.
|
80
|
+
if self.changes_to_save.has_key?(reflection.foreign_key) && self.changes_to_save[reflection.foreign_key][1].nil?
|
59
81
|
self.assign_attributes({ cache_column => current_time_from_proper_timezone })
|
60
|
-
elsif (self.
|
82
|
+
elsif (self.changes_to_save[reflection.foreign_key] || self.new_record? || (self.association(reflection.name).loaded? && self.send(reflection.name) && self.send(reflection.name).id.nil?)) && self.send(reflection.name).try(:cached_at)
|
61
83
|
self.assign_attributes({ cache_column => self.send(reflection.name).cached_at })
|
62
84
|
end
|
63
85
|
end
|
64
86
|
|
65
87
|
end
|
66
88
|
end
|
67
|
-
|
89
|
+
|
68
90
|
end
|
69
91
|
end
|
70
92
|
|
data/lib/cached_at/helpers.rb
CHANGED
@@ -29,16 +29,40 @@ module CachedAt
|
|
29
29
|
|
30
30
|
end
|
31
31
|
|
32
|
-
def cache_key(includes
|
32
|
+
def cache_key(*includes)
|
33
33
|
if includes.nil? || includes.empty?
|
34
|
-
|
34
|
+
if cache_versioning
|
35
|
+
"#{model_name.cache_key}/#{id}"
|
36
|
+
else
|
37
|
+
"#{model_name.cache_key}/#{id}@#{cache_version}"
|
38
|
+
end
|
39
|
+
else
|
40
|
+
digest = Digest::MD5.hexdigest(paramaterize_cache_includes(includes))
|
41
|
+
if cache_versioning
|
42
|
+
"#{model_name.cache_key}/#{id}+#{digest}"
|
43
|
+
else
|
44
|
+
"#{model_name.cache_key}/#{id}+#{digest}@#{cache_version(includes)}"
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
def cache_key_with_version(*includes)
|
50
|
+
if version = cache_version(*includes)
|
51
|
+
"#{cache_key(*includes)}-#{version}"
|
52
|
+
else
|
53
|
+
cache_key(*includes)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
def cache_version(*includes)
|
58
|
+
timestamp = if includes.empty?
|
59
|
+
try(:cached_at) || try(:cached_at)
|
35
60
|
else
|
36
61
|
timestamp_keys = ['cached_at'] + self.class.cached_at_columns_for_includes(includes)
|
37
|
-
timestamp =
|
38
|
-
digest ||= Digest::MD5.new()
|
39
|
-
digest << paramaterize_cache_includes(includes)
|
40
|
-
"#{model_name.cache_key}/#{id}+#{digest.hexdigest}@#{timestamp}"
|
62
|
+
timestamp = timestamp_keys.map { |attr| self[attr]&.to_time }.compact.max
|
41
63
|
end
|
64
|
+
|
65
|
+
timestamp.utc.to_s(:usec)
|
42
66
|
end
|
43
67
|
|
44
68
|
# TODO
|
@@ -84,4 +108,4 @@ module CachedAt
|
|
84
108
|
end
|
85
109
|
end
|
86
110
|
|
87
|
-
ActiveRecord::Base.include(CachedAt::Base::Helpers)
|
111
|
+
ActiveRecord::Base.include(CachedAt::Base::Helpers)
|
data/lib/cached_at/timestamp.rb
CHANGED
@@ -7,11 +7,13 @@ module ActiveRecord
|
|
7
7
|
private
|
8
8
|
|
9
9
|
def timestamp_attributes_for_update
|
10
|
-
[
|
10
|
+
["updated_at", "updated_on", 'cached_at'].map! { |name| attribute_aliases[name] || name }
|
11
11
|
end
|
12
12
|
|
13
13
|
def timestamp_attributes_for_create
|
14
|
-
['created_at', 'udpated_at', 'cached_at'] + column_names.select{|c| c.end_with?('_cached_at') }
|
14
|
+
(['created_at', 'udpated_at', 'cached_at'] + column_names.select{|c| c.end_with?('_cached_at') }).map! do |name|
|
15
|
+
attribute_aliases[name] || name
|
16
|
+
end
|
15
17
|
end
|
16
18
|
|
17
19
|
end
|
data/lib/cached_at/version.rb
CHANGED
metadata
CHANGED
@@ -1,29 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: activerecord-cached_at
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 6.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jon Bracy
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-01-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 6.1.0
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
26
|
+
version: 6.1.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: bundler
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -143,8 +143,6 @@ files:
|
|
143
143
|
- lib/cached_at/associations/has_many_through_association.rb
|
144
144
|
- lib/cached_at/associations/has_one_association.rb
|
145
145
|
- lib/cached_at/base.rb
|
146
|
-
- lib/cached_at/connection_adapters/abstract/schema_definitions.rb
|
147
|
-
- lib/cached_at/connection_adapters/abstract/schema_statements.rb
|
148
146
|
- lib/cached_at/helpers.rb
|
149
147
|
- lib/cached_at/reflections/abstract_reflection.rb
|
150
148
|
- lib/cached_at/timestamp.rb
|
@@ -153,7 +151,7 @@ homepage: https://github.com/malomalo/activerecord-cached_at
|
|
153
151
|
licenses:
|
154
152
|
- MIT
|
155
153
|
metadata: {}
|
156
|
-
post_install_message:
|
154
|
+
post_install_message:
|
157
155
|
rdoc_options:
|
158
156
|
- "--main"
|
159
157
|
- README.md
|
@@ -170,9 +168,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
170
168
|
- !ruby/object:Gem::Version
|
171
169
|
version: '0'
|
172
170
|
requirements: []
|
173
|
-
|
174
|
-
|
175
|
-
signing_key:
|
171
|
+
rubygems_version: 3.2.3
|
172
|
+
signing_key:
|
176
173
|
specification_version: 4
|
177
174
|
summary: Allows ActiveRecord and Rails to use a `cached_at` column for the `cache_key`
|
178
175
|
if available
|
@@ -1,17 +0,0 @@
|
|
1
|
-
module ActiveRecord
|
2
|
-
module ConnectionAdapters #:nodoc:
|
3
|
-
|
4
|
-
class TableDefinition
|
5
|
-
def timestamps(*args)
|
6
|
-
options = args.extract_options!
|
7
|
-
|
8
|
-
options[:null] = false if options[:null].nil?
|
9
|
-
|
10
|
-
column(:created_at, :datetime, options)
|
11
|
-
column(:updated_at, :datetime, options)
|
12
|
-
column(:cached_at, :datetime, options)
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
end
|
17
|
-
end
|
@@ -1,21 +0,0 @@
|
|
1
|
-
module ActiveRecord
|
2
|
-
module ConnectionAdapters #:nodoc:
|
3
|
-
|
4
|
-
module SchemaStatements
|
5
|
-
def add_timestamps(table_name, options = {})
|
6
|
-
options[:null] = false if options[:null].nil?
|
7
|
-
|
8
|
-
add_column table_name, :created_at, :datetime, options
|
9
|
-
add_column table_name, :updated_at, :datetime, options
|
10
|
-
add_column table_name, :cached_at, :datetime, options
|
11
|
-
end
|
12
|
-
|
13
|
-
def remove_timestamps(table_name, options = {})
|
14
|
-
remove_column table_name, :updated_at
|
15
|
-
remove_column table_name, :created_at
|
16
|
-
remove_column table_name, :cached_at
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
end
|
21
|
-
end
|