Class: Gitlab::Import::PageKeyset
- Inherits:
-
Object
- Object
- Gitlab::Import::PageKeyset
- Defined in:
- lib/gitlab/import/page_keyset.rb
Overview
PageKeyset can be used to keep track of the last imported page of a collection, allowing workers to resume where they left off in the event of an error.
Constant Summary collapse
- CACHE_KEY =
The base cache key to use for storing the last key.
'%{import_type}/page-keyset/%{object}/%{collection}'
Instance Attribute Summary collapse
-
#cache_key ⇒ Object
readonly
Returns the value of attribute cache_key.
Instance Method Summary collapse
-
#current ⇒ String
Get the current value from the cache.
-
#expire! ⇒ Boolean
Expire the key.
-
#initialize(object, collection, import_type) ⇒ PageKeyset
constructor
A new instance of PageKeyset.
-
#set(value) ⇒ String
Set the key to the given value.
Constructor Details
#initialize(object, collection, import_type) ⇒ PageKeyset
Returns a new instance of PageKeyset.
14 15 16 |
# File 'lib/gitlab/import/page_keyset.rb', line 14 def initialize(object, collection, import_type) @cache_key = format(CACHE_KEY, import_type: import_type, object: object.id, collection: collection) end |
Instance Attribute Details
#cache_key ⇒ Object (readonly)
Returns the value of attribute cache_key.
9 10 11 |
# File 'lib/gitlab/import/page_keyset.rb', line 9 def cache_key @cache_key end |
Instance Method Details
#current ⇒ String
Get the current value from the cache
29 30 31 |
# File 'lib/gitlab/import/page_keyset.rb', line 29 def current Gitlab::Cache::Import::Caching.read(cache_key) end |