identity_cache 0.5.1 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (91) hide show
  1. checksums.yaml +5 -5
  2. data/.github/probots.yml +2 -0
  3. data/.github/workflows/ci.yml +26 -0
  4. data/.gitignore +1 -0
  5. data/.rubocop.yml +5 -0
  6. data/.travis.yml +24 -9
  7. data/CHANGELOG.md +21 -0
  8. data/Gemfile +5 -1
  9. data/README.md +28 -26
  10. data/Rakefile +14 -5
  11. data/dev.yml +9 -16
  12. data/gemfiles/Gemfile.latest-release +6 -0
  13. data/gemfiles/Gemfile.rails-edge +6 -0
  14. data/gemfiles/Gemfile.rails52 +6 -0
  15. data/identity_cache.gemspec +26 -10
  16. data/lib/identity_cache.rb +49 -46
  17. data/lib/identity_cache/belongs_to_caching.rb +12 -40
  18. data/lib/identity_cache/cache_fetcher.rb +6 -5
  19. data/lib/identity_cache/cache_hash.rb +2 -2
  20. data/lib/identity_cache/cache_invalidation.rb +4 -11
  21. data/lib/identity_cache/cache_key_generation.rb +17 -65
  22. data/lib/identity_cache/cache_key_loader.rb +128 -0
  23. data/lib/identity_cache/cached.rb +7 -0
  24. data/lib/identity_cache/cached/association.rb +87 -0
  25. data/lib/identity_cache/cached/attribute.rb +123 -0
  26. data/lib/identity_cache/cached/attribute_by_multi.rb +37 -0
  27. data/lib/identity_cache/cached/attribute_by_one.rb +88 -0
  28. data/lib/identity_cache/cached/belongs_to.rb +93 -0
  29. data/lib/identity_cache/cached/embedded_fetching.rb +41 -0
  30. data/lib/identity_cache/cached/prefetcher.rb +51 -0
  31. data/lib/identity_cache/cached/primary_index.rb +97 -0
  32. data/lib/identity_cache/cached/recursive/association.rb +68 -0
  33. data/lib/identity_cache/cached/recursive/has_many.rb +9 -0
  34. data/lib/identity_cache/cached/recursive/has_one.rb +9 -0
  35. data/lib/identity_cache/cached/reference/association.rb +16 -0
  36. data/lib/identity_cache/cached/reference/has_many.rb +105 -0
  37. data/lib/identity_cache/cached/reference/has_one.rb +100 -0
  38. data/lib/identity_cache/configuration_dsl.rb +53 -215
  39. data/lib/identity_cache/encoder.rb +95 -0
  40. data/lib/identity_cache/expiry_hook.rb +36 -0
  41. data/lib/identity_cache/fallback_fetcher.rb +2 -1
  42. data/lib/identity_cache/load_strategy/eager.rb +28 -0
  43. data/lib/identity_cache/load_strategy/lazy.rb +71 -0
  44. data/lib/identity_cache/load_strategy/load_request.rb +20 -0
  45. data/lib/identity_cache/load_strategy/multi_load_request.rb +27 -0
  46. data/lib/identity_cache/memoized_cache_proxy.rb +127 -58
  47. data/lib/identity_cache/parent_model_expiration.rb +45 -11
  48. data/lib/identity_cache/query_api.rb +128 -394
  49. data/lib/identity_cache/railtie.rb +8 -0
  50. data/lib/identity_cache/record_not_found.rb +6 -0
  51. data/lib/identity_cache/should_use_cache.rb +1 -0
  52. data/lib/identity_cache/version.rb +3 -2
  53. data/lib/identity_cache/with_primary_index.rb +136 -0
  54. data/lib/identity_cache/without_primary_index.rb +24 -3
  55. data/performance/cache_runner.rb +28 -34
  56. data/performance/cpu.rb +3 -2
  57. data/performance/externals.rb +4 -3
  58. data/performance/profile.rb +6 -5
  59. data/railgun.yml +16 -0
  60. metadata +44 -73
  61. data/Gemfile.rails42 +0 -6
  62. data/Gemfile.rails50 +0 -6
  63. data/test/attribute_cache_test.rb +0 -110
  64. data/test/cache_fetch_includes_test.rb +0 -46
  65. data/test/cache_hash_test.rb +0 -14
  66. data/test/cache_invalidation_test.rb +0 -139
  67. data/test/deeply_nested_associated_record_test.rb +0 -19
  68. data/test/denormalized_has_many_test.rb +0 -214
  69. data/test/denormalized_has_one_test.rb +0 -160
  70. data/test/fetch_multi_test.rb +0 -308
  71. data/test/fetch_test.rb +0 -258
  72. data/test/fixtures/serialized_record.mysql2 +0 -0
  73. data/test/fixtures/serialized_record.postgresql +0 -0
  74. data/test/helpers/active_record_objects.rb +0 -106
  75. data/test/helpers/database_connection.rb +0 -72
  76. data/test/helpers/serialization_format.rb +0 -51
  77. data/test/helpers/update_serialization_format.rb +0 -27
  78. data/test/identity_cache_test.rb +0 -29
  79. data/test/index_cache_test.rb +0 -161
  80. data/test/memoized_attributes_test.rb +0 -59
  81. data/test/memoized_cache_proxy_test.rb +0 -107
  82. data/test/normalized_belongs_to_test.rb +0 -107
  83. data/test/normalized_has_many_test.rb +0 -231
  84. data/test/normalized_has_one_test.rb +0 -9
  85. data/test/prefetch_associations_test.rb +0 -379
  86. data/test/readonly_test.rb +0 -109
  87. data/test/recursive_denormalized_has_many_test.rb +0 -131
  88. data/test/save_test.rb +0 -82
  89. data/test/schema_change_test.rb +0 -112
  90. data/test/serialization_format_change_test.rb +0 -16
  91. data/test/test_helper.rb +0 -140
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: c9803848d2879cfdaad2424842b64db3684e1ca4
4
- data.tar.gz: 91cd873cffd35d19d66b01c8a10165344b30483d
2
+ SHA256:
3
+ metadata.gz: 9236be16375bc831c91f69bcc86968cf036c361c173e79cfd8ea4eb43d707787
4
+ data.tar.gz: 45e4acef2ef66d7262ce1b4c6d7b7fa33762c26fa99f31700cd44a4091dde8c4
5
5
  SHA512:
6
- metadata.gz: d65519bb48cdae9d0111280e05a89cee2e99a497f31d0140f3e77ca55226865ef8c575ec9bd427e41ba9fd105e304c0a006d2fa4348ce6b06393c0ed607a8e23
7
- data.tar.gz: 370c4a4d3406b95b9fe40b33406182286d9586dc07db2f2517a87bb08111fafa776dead8a5430555564aefdb385a9f5ce027c511e87c32924a8e8668af00a863
6
+ metadata.gz: 7f9c79056ccbb938299b3fb6fd3e62af44f9117140df1b714a758be2aa4d864ffb1df589ba0a6220786db3bdb005326e794ea9340629146e478ffb2f3a3574cf
7
+ data.tar.gz: abc0e209fe35c8fc5ed6e470221a3e86cdeca23e81fc5c294d817cf3011c9ccf3a8dbf58096414c84be4b6b1e40ce4816b36703ed2b72da7dbafa4a78235e51d
@@ -0,0 +1,2 @@
1
+ enabled:
2
+ - cla
@@ -0,0 +1,26 @@
1
+ name: CI
2
+
3
+ on: [push]
4
+
5
+ jobs:
6
+ build:
7
+
8
+ runs-on: ubuntu-latest
9
+
10
+ steps:
11
+ - uses: actions/checkout@v2
12
+ - name: Set up Ruby 2.6
13
+ uses: actions/setup-ruby@v1
14
+ with:
15
+ ruby-version: 2.6.x
16
+ - name: Install required packages
17
+ run: |
18
+ sudo apt-get update
19
+ sudo apt-get -y install libmysqlclient-dev libpq-dev libsasl2-dev
20
+ - name: Install bundler and gems
21
+ run: |
22
+ gem install bundler
23
+ bundle install --jobs 4 --retry 3
24
+ - name: Run rubocop
25
+ run: |
26
+ bundle exec rubocop
data/.gitignore CHANGED
@@ -15,3 +15,4 @@ spec/reports
15
15
  test/tmp
16
16
  test/version_tmp
17
17
  tmp
18
+ .rubocop-http*
@@ -0,0 +1,5 @@
1
+ inherit_from:
2
+ - https://shopify.github.io/ruby-style-guide/rubocop.yml
3
+
4
+ AllCops:
5
+ TargetRubyVersion: 2.6
@@ -1,25 +1,29 @@
1
1
  language: ruby
2
2
 
3
3
  rvm:
4
- - '2.2.6'
5
- - '2.3.3'
4
+ - 2.4
5
+ - 2.6
6
6
 
7
7
  gemfile:
8
- - Gemfile.rails42
9
- - Gemfile.rails50
10
-
11
- matrix:
12
- exclude:
13
- - gemfile: Gemfile.rails50
14
- env: DB=postgresql
8
+ - gemfiles/Gemfile.rails52
9
+ - gemfiles/Gemfile.latest-release
10
+ - gemfiles/Gemfile.rails-edge
15
11
 
16
12
  env:
17
13
  - DB=mysql2
18
14
  - DB=postgresql
19
15
 
16
+ jobs:
17
+ exclude:
18
+ - rvm: 2.4
19
+ gemfile: gemfiles/Gemfile.rails-edge
20
+ - rvm: 2.4
21
+ gemfile: gemfiles/Gemfile.latest-release
22
+
20
23
  services:
21
24
  - memcache
22
25
  - mysql
26
+ - postgresql
23
27
 
24
28
  sudo: false
25
29
 
@@ -27,4 +31,15 @@ before_script:
27
31
  - mysql -e 'create database identity_cache_test'
28
32
  - psql -c 'create database identity_cache_test;' -U postgres
29
33
 
34
+ script:
35
+ - bundle exec rake test
36
+
30
37
  cache: bundler
38
+
39
+ matrix:
40
+ exclude:
41
+ - rvm: 2.2.6
42
+ gemfile: gemfiles/Gemfile.rails-edge
43
+
44
+ notifications:
45
+ email: false
@@ -1,5 +1,26 @@
1
1
  # IdentityCache changelog
2
2
 
3
+ #### 1.0.0
4
+
5
+ - Remove inverse_name option. Specify inverse_of on the Active Record association instead. (#439)
6
+ - Bump the minimum Active Record version to 5.2 (#438)
7
+ - Remove the default embed option value from cache_has_one (#437)
8
+ - Lazily evaluate nested includes to fetch blobs in batches (#427)
9
+ - Only cache embedded association IDs when present (#397)
10
+ - Add support for ID embedded `has_one` cached associations (#393)
11
+ - Add support for polymorphic `belongs_to` cached associations (#387)
12
+ - Add `fetch_multi_by_*` support for cache_index with a single field (#368)
13
+ - Remove support for rails 4.2 (#355)
14
+ - Type cast values using attribute types before using in cache key (#354)
15
+ - Set inverse cached association for cache_has_one on cache hit (#345)
16
+ - Use `ActiveSupport:Notifications` to notify subscribers of hydration events (#341)
17
+ - Remove disable_primary_cache_index (#335)
18
+ - Remove deprecated `embed: false` cache_has_many option (#335)
19
+ - Fix column name in the preload association query when using custom primary keys (#338)
20
+ - Raise when trying to cache a belong_to association with a scope. Previously the scope was ignored on a cache hit (#323)
21
+ - Remove deprecated `never_set_inverse_association` option (#319)
22
+ - Lazy load associated classes (#306)
23
+
3
24
  #### 0.5.1
4
25
 
5
26
  - Fix bug in prefetch_associations for cache_has_one associations that may be nil
data/Gemfile CHANGED
@@ -1,4 +1,8 @@
1
+ # frozen_string_literal: true
1
2
  source 'https://rubygems.org'
2
3
  gemspec
3
4
 
4
- gem 'mysql2', '~> 0.3.13'
5
+ gem 'mysql2', '~> 0.5.3'
6
+ gem 'pg', '~> 0.21.0'
7
+ gem 'rubocop'
8
+ gem 'byebug', platform: :mri
data/README.md CHANGED
@@ -12,6 +12,7 @@ Add this line to your application's Gemfile:
12
12
  ```ruby
13
13
  gem 'identity_cache'
14
14
  gem 'cityhash' # optional, for faster hashing (C-Ruby only)
15
+ gem 'memcached_store' # for CAS support, needed for cache consistency
15
16
  ```
16
17
 
17
18
  And then execute:
@@ -22,7 +23,12 @@ And then execute:
22
23
  Add the following to all your environment/*.rb files (production/development/test):
23
24
 
24
25
  ```ruby
25
- config.identity_cache_store = :mem_cache_store, Memcached::Rails.new(:servers => ["mem1.server.com"])
26
+ config.identity_cache_store = :memcached_store,
27
+ Memcached::Rails.new(servers: ["mem1.server.com"],
28
+ support_cas: true,
29
+ auto_eject_hosts: false, # avoids more cache consistency issues
30
+ expires_in: 6.hours.to_i, # in case of network errors when sending a delete
31
+ )
26
32
  ```
27
33
 
28
34
  Add an initializer with this code:
@@ -45,10 +51,10 @@ class Product < ActiveRecord::Base
45
51
 
46
52
  has_many :images
47
53
 
48
- cache_has_many :images, :embed => true
54
+ cache_has_many :images, embed: true
49
55
  end
50
56
 
51
- # Fetch the product by its id using the primary primary index as well as the embedded images association.
57
+ # Fetch the product by its id using the primary index as well as the embedded images association.
52
58
  @product = Product.fetch(id)
53
59
 
54
60
  # Access the loaded images for the Product.
@@ -64,7 +70,7 @@ IdentityCache lets you lookup records by fields other than `id`. You can have mu
64
70
  ``` ruby
65
71
  class Product < ActiveRecord::Base
66
72
  include IdentityCache
67
- cache_index :handle, :unique => true
73
+ cache_index :handle, unique: true
68
74
  cache_index :vendor, :product_type
69
75
  end
70
76
 
@@ -72,6 +78,9 @@ end
72
78
  # If the object isn't in the cache it is pulled from the db and stored in the cache.
73
79
  product = Product.fetch_by_handle(handle)
74
80
 
81
+ # Fetch multiple products by providing an array of index values.
82
+ products = Product.fetch_multi_by_handle(handles)
83
+
75
84
  products = Product.fetch_by_vendor_and_product_type(vendor, product_type)
76
85
  ```
77
86
 
@@ -98,7 +107,7 @@ class Product < ActiveRecord::Base
98
107
  has_one :featured_image
99
108
 
100
109
  cache_has_many :images
101
- cache_has_one :featured_image
110
+ cache_has_one :featured_image, embed: :id
102
111
  end
103
112
 
104
113
  @product.fetch_featured_image
@@ -112,7 +121,7 @@ class Product < ActiveRecord::Base
112
121
  include IdentityCache
113
122
  end
114
123
 
115
- @product.fetch_multi([1, 2])
124
+ Product.fetch_multi([1, 2])
116
125
  ```
117
126
 
118
127
  ### Embedding Associations
@@ -124,7 +133,7 @@ class Product < ActiveRecord::Base
124
133
  include IdentityCache
125
134
 
126
135
  has_many :images
127
- cache_has_many :images, :embed => true
136
+ cache_has_many :images, embed: true
128
137
  end
129
138
 
130
139
  @product = Product.fetch(id)
@@ -135,32 +144,29 @@ With this code, on cache miss, the product and its associated images will be loa
135
144
 
136
145
  ### Caching Polymorphic Associations
137
146
 
138
- IdentityCache tries to figure out both sides of an association whenever it can so it can set those up when rebuilding the object from the cache. In some cases this is hard to determine so you can tell IdentityCache what the association should be. This is most often the case when embedding polymorphic associations. The `inverse_name` option on `cache_has_many` and `cache_has_one` lets you specify the inverse name of the association.
147
+ IdentityCache tries to figure out both sides of an association whenever it can so it can set those up when rebuilding the object from the cache. In some cases this is hard to determine so you can tell IdentityCache what the association should be. This is most often the case when embedding polymorphic associations.
139
148
 
140
149
  ``` ruby
141
150
  class Metafield < ActiveRecord::Base
142
151
  include IdentityCache
143
- belongs_to :owner, :polymorphic => true
152
+ belongs_to :owner, polymorphic: true
144
153
  cache_belongs_to :owner
145
154
  end
146
155
 
147
156
  class Product < ActiveRecord::Base
148
157
  include IdentityCache
149
- has_many :metafields, :as => 'owner'
150
- cache_has_many :metafields, :inverse_name => :owner
158
+ has_many :metafields, as: :owner
159
+ cache_has_many :metafields
151
160
  end
152
161
  ```
153
162
 
154
- The `:inverse_name => :owner` option tells IdentityCache what the association on the other side is named so that it can correctly set the assocation when loading the metafields from the cache.
155
-
156
-
157
163
  ### Caching Attributes
158
164
 
159
165
  For cases where you may not need the entire object to be cached, just an attribute from record, `cache_attribute` can be used. This will cache the single attribute by the key specified.
160
166
 
161
167
  ``` ruby
162
168
  class Redirect < ActiveRecord::Base
163
- cache_attribute :target, :by => [:shop_id, :path]
169
+ cache_attribute :target, by: [:shop_id, :path]
164
170
  end
165
171
 
166
172
  Redirect.fetch_target_by_shop_id_and_path(shop_id, path)
@@ -182,22 +188,18 @@ Example:
182
188
  #### cache_has_many
183
189
 
184
190
  Options:
185
- _[:embed]_ When true, specifies that the association should be included with the parent when caching. This means the associated objects will be loaded already when the parent is loaded from the cache and will not need to be fetched on their own. When :ids, only the id of the associated records will be included with the parent when caching.
186
-
187
- _[:inverse_name]_ Specifies the name of parent object used by the association. This is useful for polymorphic associations when the association is often named something different between the parent and child objects.
191
+ _[:embed]_ When true, specifies that the association should be included with the parent when caching. This means the associated objects will be loaded already when the parent is loaded from the cache and will not need to be fetched on their own. When :ids, only the id of the associated records will be included with the parent when caching. Defaults to `:ids`.
188
192
 
189
193
  Example:
190
- `cache_has_many :metafields, :inverse_name => :owner, :embed => true`
194
+ `cache_has_many :metafields, embed: true`
191
195
 
192
196
  #### cache_has_one
193
197
 
194
198
  Options:
195
- _[:embed]_ When true, specifies that the association should be included with the parent when caching. This means the associated objects will be loaded already when the parent is loaded from the cache and will not need to be fetched on their own. No other values are currently implemented.
196
-
197
- _[:inverse_name]_ Specifies the name of parent object used by the association. This is useful for polymorphic associations when the association is often named something different between the parent and child objects.
199
+ _[:embed]_ When true, specifies that the association should be included with the parent when caching. This means the associated objects will be loaded already when the parent is loaded from the cache and will not need to be fetched on their own. No other values are currently implemented. When :id, only the id of the associated record will be included with the parent when caching.
198
200
 
199
201
  Example:
200
- `cache_has_one :configuration, :embed => true`
202
+ `cache_has_one :configuration, embed: :id`
201
203
 
202
204
  #### cache_belongs_to
203
205
 
@@ -210,7 +212,7 @@ Options:
210
212
  _[:by]_ Specifies what key(s) you want the attribute cached by. Defaults to :id.
211
213
 
212
214
  Example:
213
- `cache_attribute :target, :by => [:shop_id, :path]`
215
+ `cache_attribute :target, by: [:shop_id, :path]`
214
216
 
215
217
  ## Memoized Cache Proxy
216
218
 
@@ -220,8 +222,8 @@ Cache reads and writes can be memoized for a block of code to serve duplicate id
220
222
  class ApplicationController < ActionController::Base
221
223
  around_filter :identity_cache_memoization
222
224
 
223
- def identity_cache_memoization
224
- IdentityCache.cache.with_memoization{ yield }
225
+ def identity_cache_memoization(&block)
226
+ IdentityCache.cache.with_memoization(&block)
225
227
  end
226
228
  end
227
229
  ```
data/Rakefile CHANGED
@@ -1,13 +1,14 @@
1
1
  #!/usr/bin/env rake
2
+ # frozen_string_literal: true
2
3
  require 'bundler/gem_tasks'
3
4
 
4
5
  require 'rake/testtask'
5
6
  require 'rdoc/task'
6
7
 
7
- desc 'Default: run unit tests.'
8
- task :default => :test
8
+ desc('Default: run tests and style checks.')
9
+ task(default: [:test, :rubocop])
9
10
 
10
- desc 'Test the identity_cache plugin.'
11
+ desc('Test the identity_cache plugin.')
11
12
  Rake::TestTask.new(:test) do |t|
12
13
  t.libs << 'lib'
13
14
  t.libs << 'test'
@@ -15,9 +16,17 @@ Rake::TestTask.new(:test) do |t|
15
16
  t.verbose = true
16
17
  end
17
18
 
18
- desc 'Update serialization format test fixture.'
19
+ task :rubocop do
20
+ require 'rubocop/rake_task'
21
+ RuboCop::RakeTask.new
22
+ end
23
+
24
+ desc('Update serialization format test fixture.')
19
25
  task :update_serialization_format do
20
- ruby './test/helpers/update_serialization_format.rb'
26
+ %w(mysql2 postgresql).each do |db|
27
+ ENV["DB"] = db
28
+ ruby './test/helpers/update_serialization_format.rb'
29
+ end
21
30
  end
22
31
 
23
32
  namespace :benchmark do
data/dev.yml CHANGED
@@ -3,7 +3,7 @@ name: identity-cache
3
3
  up:
4
4
  - homebrew:
5
5
  - postgresql
6
- - ruby: 2.3.3
6
+ - ruby: 2.4.1
7
7
  - railgun
8
8
  - bundler
9
9
 
@@ -27,6 +27,14 @@ commands:
27
27
  bundle exec ruby -I test "$@"
28
28
  fi
29
29
 
30
+ style:
31
+ desc: 'Run rubocop checks'
32
+ run: bundle exec rubocop "$@"
33
+
34
+ check:
35
+ desc: 'Run tests and style checks'
36
+ run: bundle exec rake test && bundle exec rubocop
37
+
30
38
  benchmark-cpu:
31
39
  desc: 'Run the identity cache CPU benchmark'
32
40
  run: bundle exec rake benchmark:cpu
@@ -38,18 +46,3 @@ commands:
38
46
  update-serialization-format:
39
47
  desc: 'Update serialization format test fixture'
40
48
  run: bundle exec rake update_serialization_format
41
-
42
- railgun:
43
- image: dev:railgun-common-services-0.2.x
44
- ip_address: 192.168.64.98
45
- memory: 1G
46
- cores: 1
47
- disk: 1G
48
- services:
49
- mysql: 3306
50
- postgresql: 5432
51
- memcached: 11211
52
-
53
- packages:
54
- - git@github.com:Shopify/dev-shopify.git
55
-
@@ -0,0 +1,6 @@
1
+ source 'https://rubygems.org'
2
+ gemspec path: '..'
3
+
4
+ gem 'activerecord'
5
+ gem 'activesupport'
6
+ gem "mysql2", ">= 0.4.4"
@@ -0,0 +1,6 @@
1
+ source 'https://rubygems.org'
2
+ gemspec path: '..'
3
+
4
+ gem 'activerecord', github: 'rails/rails'
5
+ gem 'activesupport', github: 'rails/rails'
6
+ gem "mysql2", ">= 0.4.4"
@@ -0,0 +1,6 @@
1
+ source 'https://rubygems.org'
2
+ gemspec path: '..'
3
+
4
+ gem 'activerecord', '~> 5.2'
5
+ gem 'activesupport', '~> 5.2'
6
+ gem 'mysql2', '>= 0.4.4', '< 0.6.0'
@@ -1,24 +1,40 @@
1
1
  # -*- encoding: utf-8 -*-
2
+ # frozen_string_literal: true
2
3
  require File.expand_path('../lib/identity_cache/version', __FILE__)
3
4
 
4
5
  Gem::Specification.new do |gem|
5
- gem.authors = ["Camilo Lopez", "Tom Burns", "Harry Brundage", "Dylan Thacker-Smith", "Tobias Lutke", "Arthur Neves", "Francis Bogsanyi"]
6
+ gem.authors = [
7
+ "Camilo Lopez",
8
+ "Tom Burns",
9
+ "Harry Brundage",
10
+ "Dylan Thacker-Smith",
11
+ "Tobias Lutke",
12
+ "Arthur Neves",
13
+ "Francis Bogsanyi",
14
+ ]
6
15
  gem.email = ["gems@shopify.com"]
7
- gem.description = %q{Opt in read through ActiveRecord caching.}
8
- gem.summary = %q{IdentityCache lets you specify how you want to cache your model objects, at the model level, and adds a number of convenience methods for accessing those objects through the cache. Memcached is used as the backend cache store, and the database is only hit when a copy of the object cannot be found in Memcached.}
16
+ gem.description = "Opt-in read through Active Record caching."
17
+ gem.summary = "IdentityCache lets you specify how you want to cache your " \
18
+ "model objects, at the model level, and adds a number of " \
19
+ "convenience methods for accessing those objects through " \
20
+ "the cache. Memcached is used as the backend cache store, " \
21
+ "and the database is only hit when a copy of the object " \
22
+ "cannot be found in Memcached."
9
23
  gem.homepage = "https://github.com/Shopify/identity_cache"
10
24
 
11
- gem.files = `git ls-files`.split($\)
12
- gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
13
- gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
25
+ gem.files = Dir.chdir(File.expand_path(__dir__)) do
26
+ %x(git ls-files -z).split("\x0").reject { |f| f.match(%r{^test/}) }
27
+ end
28
+ gem.executables = gem.files.grep(%r{^bin/}).map { |f| File.basename(f) }
29
+ gem.test_files = gem.files.grep(%r{^test/})
14
30
  gem.name = "identity_cache"
15
31
  gem.require_paths = ["lib"]
16
32
  gem.version = IdentityCache::VERSION
17
33
 
18
- gem.required_ruby_version = '>= 2.2.0'
34
+ gem.required_ruby_version = '>= 2.4.0'
19
35
 
20
36
  gem.add_dependency('ar_transaction_changes', '~> 1.0')
21
- gem.add_dependency('activerecord', '>= 4.2.0')
37
+ gem.add_dependency('activerecord', '>= 5.2')
22
38
 
23
39
  gem.add_development_dependency('memcached', '~> 1.8.0')
24
40
  gem.add_development_dependency('memcached_store', '~> 1.0.0')
@@ -32,7 +48,7 @@ Gem::Specification.new do |gem|
32
48
  else
33
49
  gem.add_development_dependency('cityhash', '0.6.0')
34
50
  gem.add_development_dependency('mysql2')
35
- gem.add_development_dependency('pg')
36
- gem.add_development_dependency('stackprof') if Gem::Version.new(RUBY_VERSION.dup) >= Gem::Version.new("2.1.0")
51
+ gem.add_development_dependency('pg', '~> 0.18')
52
+ gem.add_development_dependency('stackprof')
37
53
  end
38
54
  end