para 0.12.9 → 0.12.10
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 +4 -4
- data/lib/para/cache/database_store.rb +20 -2
- data/lib/para/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: e4cbe4fb5e062beed059dc791472978c89615505a9f7e148d72499293ccb71f3
|
|
4
|
+
data.tar.gz: 2affb52073121cab65975dd8b4b79929bd1a599662adc80dfe10c56a77db2b42
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: c8adbf077aa46ed899aae4e4aebfbcefae4925d9b3980bf0bbb77deb49bd05bdbc677fa52148447661cbf62d3413a7737a3d40a52c7a07b3f760a11e769ee581
|
|
7
|
+
data.tar.gz: f787f506e622ff1dffb71bbbed59f7698fef56bda83e5a4c25e8fac2d68822b9c2135e0fe5cbba13897663122afc49876fe66289f14c0659b554851b201ce34b
|
|
@@ -47,9 +47,19 @@ module Para
|
|
|
47
47
|
# imports, that use the cache inside transactions but need other
|
|
48
48
|
# processes to get their state in real time.
|
|
49
49
|
#
|
|
50
|
-
|
|
50
|
+
# Outside of a transaction, the item is saved with the current connection,
|
|
51
|
+
# because the thread needs a second connection from the pool while the
|
|
52
|
+
# current thread keeps its own. When all the pool connections are held by
|
|
53
|
+
# busy threads, like background jobs that write their status, the thread
|
|
54
|
+
# waits for a connection until it times out.
|
|
55
|
+
#
|
|
56
|
+
if inside_transaction?
|
|
57
|
+
Thread.new do
|
|
58
|
+
item.save!
|
|
59
|
+
end.join
|
|
60
|
+
else
|
|
51
61
|
item.save!
|
|
52
|
-
end
|
|
62
|
+
end
|
|
53
63
|
|
|
54
64
|
# Ensure cached item in RequestStore is up to date
|
|
55
65
|
RequestStore.store[cache_key_for(key)] = item
|
|
@@ -60,6 +70,14 @@ module Para
|
|
|
60
70
|
|
|
61
71
|
private
|
|
62
72
|
|
|
73
|
+
# The pool returns the connection already held by the current thread, or nil,
|
|
74
|
+
# so we don't check out a connection just to know if a transaction is open.
|
|
75
|
+
#
|
|
76
|
+
def inside_transaction?
|
|
77
|
+
connection = Item.connection_pool.active_connection?
|
|
78
|
+
connection && connection.transaction_open?
|
|
79
|
+
end
|
|
80
|
+
|
|
63
81
|
def clear_expired_keys
|
|
64
82
|
if Item.count > Para.config.database_cache_store_max_items
|
|
65
83
|
remove_expired_items
|
data/lib/para/version.rb
CHANGED