gitlab-client-cache 0.0.6 → 0.0.8

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: 07e81604666aaca0d0007b06bc627a6eb4ecd561be6d1a5b746f9fffac3dc3ac
4
- data.tar.gz: d5dffad20916417b48f60fb30fba9fef1aba268400f61186bf7da7503a9a013c
3
+ metadata.gz: 9b0e82dfc66ede983af9394fcd775e1fd5b1bd2449c3142b2424e321ca912ba9
4
+ data.tar.gz: 56091a27ca44807c8ccfcc5ac5452c324bb0990e95a32d1585a7b5f5853c9117
5
5
  SHA512:
6
- metadata.gz: 54328bd901540acd79996516ecea5a36552135bbd965f7b095599f9d06710caed5e2b81ec4b1a776d226610fd7e871ebafbf77d79799385a5ad29ecd78dfd44f
7
- data.tar.gz: 9c98c25d5c3fb3883de17d8c2d2a4aed0aeb480b30877e4740ca86ea4f8d5651fe195a2e2440796b2a122c4d47bbd94f8ed438e14fa58236300b0182f1a0731b
6
+ metadata.gz: 418150f965dcabfaa90855fca348f5399ab0fa15d014e26493eacefe5199e9265104edf43eab99fd7cf948333562e4c39646b0f948545523bc3125eb0f1d6bea
7
+ data.tar.gz: fcebb8176e19624554ea146860634d24a190817e5be70acd27e3a04218c8b43cee981e5b6744dd9bced5d8651858be0272688b22b9afb2d898d571ab0598ed78
@@ -16,12 +16,14 @@ class Gitlab::Client::Cache::Caching
16
16
 
17
17
  expires_in = determine_expires_in(args)
18
18
 
19
- if expires_in != :skip_caching && path.exist? && path_fresh?(path, expires_in)
19
+ return yield if expires_in == :skip_caching
20
+
21
+ if path.exist? && path_fresh?(path, expires_in)
20
22
  load(path)
21
23
  else
22
- result = yield
23
- dump(path, result) unless expires_in == :skip_caching
24
- result
24
+ value = yield
25
+ dump(path, value)
26
+ value
25
27
  end
26
28
  end
27
29
 
@@ -62,10 +64,19 @@ class Gitlab::Client::Cache::Caching
62
64
  Object.const_get(klass).inflate(content)
63
65
  end
64
66
 
65
- def dump(path, result)
67
+ def dump(path, value)
68
+ result = @config.before_dump&.call(value)
69
+ return if result == :skip_caching
70
+
66
71
  path.dirname.mkpath
67
- @config.before_dump&.call(result)
68
- path.write(deflate(Marshal.dump(result)))
72
+
73
+ content = deflate(Marshal.dump(result))
74
+ # Write atomatically
75
+ temp = path.sub_ext(".#{rand(2 << 32)}")
76
+ temp.write(content)
77
+ temp.rename(path)
78
+
79
+ path.write(deflate(Marshal.dump(value)))
69
80
  end
70
81
 
71
82
  def deflate(content)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module GitlabClientCache
4
- VERSION = "0.0.6"
4
+ VERSION = "0.0.8"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gitlab-client-cache
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Peter Leitzen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-07-18 00:00:00.000000000 Z
11
+ date: 2024-11-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: gitlab
@@ -59,7 +59,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
59
59
  - !ruby/object:Gem::Version
60
60
  version: '0'
61
61
  requirements: []
62
- rubygems_version: 3.5.14
62
+ rubygems_version: 3.4.19
63
63
  signing_key:
64
64
  specification_version: 4
65
65
  summary: Response cache for `gitlab` gem