simple_cache_lock 0.1.3 → 0.1.4

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: edf2db85970af02f5d022161da98fe1728935d98969913d908ae601977f1daac
4
- data.tar.gz: 85aca16dfc085862c27b3c37c11a9c518fc2363aaa8c1f8544ba5e978ea62d5e
3
+ metadata.gz: c879c36b77e537dd0ac719a378af55edf8267cdb1174a57455a1c8011d5dd48f
4
+ data.tar.gz: 2b79e4f23d7d305d005f296b97d424f5aee77139a0c7166f06070a0e04408164
5
5
  SHA512:
6
- metadata.gz: 784bf980c1e619eaefd677d0396263927a43f3db70d2440b4e04c24dbf62bee67f2fcf854fc464130431302e7c8327ce093cbd8a9004f276c23a5c6c4405537c
7
- data.tar.gz: 1c845101edc96905570198ff773ef3c1e39979e91371287bbc1e09f4fb0dd089b29921d00b9805349d2b2b0964196a4d72f534d3f5606fe143a95cfe1634f8ce
6
+ metadata.gz: f1a210591fc0460db2d14ac4345501027933e830ef4df8dbff9fac0da831f2831eac8d71405f66aec611ca378edbf89cc4b18abb6fcf0f49b55df5aa68a6c48c
7
+ data.tar.gz: abd5e232c390db9af9245659ce4b3d8a362e35485fa2daf3a2052285173dac0cd211ffa300b398d6d9330c281ef19467889b58bcb0f0a0232f3acce16ba2ab80
data/.gitignore CHANGED
@@ -9,3 +9,5 @@
9
9
 
10
10
  # rspec failure tracking
11
11
  .rspec_status
12
+ .DS_Store
13
+ *.gem
data/README.md CHANGED
@@ -1,8 +1,9 @@
1
1
  # SimpleCacheLock
2
2
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/simple_cache_lock`. To experiment with that code, run `bin/console` for an interactive prompt.
3
+ Warn: No testing added!!! Use at your risk
4
4
 
5
- TODO: Delete this and the text above, and describe your gem
5
+ Lock and wait your cache until it finished. don't let concurrent processes write
6
+ same cache_key. make them to wait instead.
6
7
 
7
8
  ## Installation
8
9
 
@@ -16,13 +16,18 @@ module SimpleCacheLock
16
16
 
17
17
  if is_locked == false
18
18
  Timeout::timeout(wait_timeout) {
19
- while is_locked = redlock.lock(lock_key, wait_lock_timeout) == false
20
- sleep rand
19
+ loop do
20
+ is_locked = redlock.lock(lock_key, wait_lock_timeout)
21
+ if is_locked == false
22
+ sleep rand
23
+ else
24
+ break
25
+ end
21
26
  end
22
27
  }
23
28
 
24
29
  if cache_store.exist? content_cache_key
25
- redlock.unlock(is_locked)
30
+ redlock.unlock(is_locked) unless is_locked
26
31
  return cache_store.read key
27
32
  end
28
33
  end
@@ -1,3 +1,3 @@
1
1
  module SimpleCacheLock
2
- VERSION = "0.1.3"
2
+ VERSION = "0.1.4"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simple_cache_lock
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Saiqul Haq