Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'lib/bulk_imports/pipeline/hexdigest_cache_strategy.rb')
-rw-r--r--lib/bulk_imports/pipeline/hexdigest_cache_strategy.rb16
1 files changed, 16 insertions, 0 deletions
diff --git a/lib/bulk_imports/pipeline/hexdigest_cache_strategy.rb b/lib/bulk_imports/pipeline/hexdigest_cache_strategy.rb
new file mode 100644
index 00000000000..51d7374f6c6
--- /dev/null
+++ b/lib/bulk_imports/pipeline/hexdigest_cache_strategy.rb
@@ -0,0 +1,16 @@
+# frozen_string_literal: true
+
+module BulkImports
+ module Pipeline
+ module HexdigestCacheStrategy
+ def already_processed?(data, _)
+ values = Gitlab::Cache::Import::Caching.values_from_set(cache_key)
+ values.include?(OpenSSL::Digest::SHA256.hexdigest(data.to_s))
+ end
+
+ def save_processed_entry(data, _)
+ Gitlab::Cache::Import::Caching.set_add(cache_key, OpenSSL::Digest::SHA256.hexdigest(data.to_s))
+ end
+ end
+ end
+end