Skip to content

Commit c9877a4

Browse files
committed
wip
1 parent a820a52 commit c9877a4

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

lib/table_sync/publishing/helpers/debounce.rb

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -124,11 +124,13 @@ def debounced_sync_time
124124
end
125125

126126
def cache_next_sync_time
127-
Rails.cache.write(
128-
cache_key,
129-
next_sync_time,
130-
expires_at: next_sync_time + debounce_time.seconds,
131-
)
127+
return if debounce_time.zero?
128+
129+
expires_at = next_sync_time + debounce_time.seconds
130+
expires_in = expires_at - Time.current
131+
return if expires_in.negative?
132+
133+
Rails.cache.write(cache_key, next_sync_time, expires_in:)
132134
end
133135

134136
def cache_key

0 commit comments

Comments
 (0)