iknow_view_models 2.8.10 → 2.9.0
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 53525088a6e3b8f394861ea5326ee235d94eb69a7b49b346ca09f26894e62f38
|
4
|
+
data.tar.gz: e394ad428ee6131d5dcdf7107ca5fea22d23eb41ab6bc6c5ba96626343180f89
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 342baae02e08f68f1f4b624c153bb9fd00144f21aef38c5623144899a4554730fd98651411e26528e05f40b16fa51136235ae1831ebc25bb4860904de465aef8
|
7
|
+
data.tar.gz: af565e5b9374ce950178437a16def8cda1b50639d2e98e5c367be5af0cacaff85ddcb7f0fc57a1a4309466e3f682760ae8a213f0ac9ed740eeed4bd9b975736e
|
@@ -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)
|
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: 2.
|
4
|
+
version: 2.9.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
|