iknow_view_models 3.0.3 → 3.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
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f9459a78038ecf77ab3855e7e4ea6a0899ac31fd3e7dd05be247d9e0b72284f3
|
4
|
+
data.tar.gz: 34d662ae8733173dd3372ef9af5cd68b133848e1a94e5b1250624ec50dd4b0eb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7841f336c7f1604e3b2dbd54fb7209be02ecae7d19100707bef4ecc9b9ef2ae4d741f74d205fe468ac7ce9f14bd359d1b67b3ec1b76507ea9b51f812d0375972
|
7
|
+
data.tar.gz: 6b7aaa8742bdb52afa77c37be699da4c4896ab25a1bb560e5b404506e4f97730dad6659c062ff1443bdb2f21ff120e205b888d3d742b372d9306062a515c8ad4
|
@@ -12,7 +12,17 @@ module ViewModel::ActiveRecord::Cache::CacheableView
|
|
12
12
|
CacheClearer = Struct.new(:cache, :id) do
|
13
13
|
include ViewModel::AfterTransactionRunner
|
14
14
|
|
15
|
-
|
15
|
+
# It's important that we clear the cache before committing, because we rely
|
16
|
+
# on database locking to prevent cache race conditions. We require
|
17
|
+
# reading/refreshing the cache to obtain a FOR SHARE lock, which means that
|
18
|
+
# a reader must wait for a concurrent writer to commit before continuing to
|
19
|
+
# the cache. If the writer cleared the cache after commit, the reader could
|
20
|
+
# obtain old data before the clear, and then save the old data after it.
|
21
|
+
def before_commit
|
22
|
+
cache.delete(id)
|
23
|
+
end
|
24
|
+
|
25
|
+
def after_rollback
|
16
26
|
cache.delete(id)
|
17
27
|
end
|
18
28
|
|
@@ -4,16 +4,31 @@
|
|
4
4
|
# `add_to_transaction`, the abstract method `after_transaction` will be invoked
|
5
5
|
# by AR's callbacks.
|
6
6
|
module ViewModel::AfterTransactionRunner
|
7
|
-
|
7
|
+
# Rails' internal API
|
8
|
+
def committed!(*)
|
9
|
+
after_commit
|
10
|
+
end
|
8
11
|
|
9
12
|
def before_committed!
|
10
|
-
|
13
|
+
before_commit
|
11
14
|
end
|
12
15
|
|
13
16
|
def rolledback!(*)
|
14
|
-
|
17
|
+
after_rollback
|
18
|
+
end
|
19
|
+
|
20
|
+
def trigger_transactional_callbacks?
|
21
|
+
true
|
15
22
|
end
|
16
23
|
|
24
|
+
# Our simplified API
|
25
|
+
|
26
|
+
def before_commit; end
|
27
|
+
|
28
|
+
def after_commit; end
|
29
|
+
|
30
|
+
def after_rollback; end
|
31
|
+
|
17
32
|
def add_to_transaction
|
18
33
|
if connection.transaction_open?
|
19
34
|
connection.add_transaction_record(self)
|
@@ -22,9 +37,6 @@ module ViewModel::AfterTransactionRunner
|
|
22
37
|
end
|
23
38
|
end
|
24
39
|
|
25
|
-
def trigger_transactional_callbacks?
|
26
|
-
true
|
27
|
-
end
|
28
40
|
|
29
41
|
# Override to tie to a specific connection.
|
30
42
|
def connection
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: iknow_view_models
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.0
|
4
|
+
version: 3.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- iKnow Team
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-09-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|