Method: Gitlab::RepositoryHashCache#read_members

Defined in:
lib/gitlab/repository_hash_cache.rb

#read_members(key, hash_keys = []) ⇒ Hash

Read the values of a set of keys from the hash store, and return them as a hash of those keys and their values.

Parameters:

  • key (String)
  • hash_keys (Array<String>) (defaults to: [])

    an array of keys to retrieve from the store

Returns:

  • (Hash)

    a Ruby hash of the provided keys and their values from the store

Raises:



67
68
69
70
71
72
73
74
75
76
77
# File 'lib/gitlab/repository_hash_cache.rb', line 67

def read_members(key, hash_keys = [])
  raise InvalidKeysProvidedError unless hash_keys.is_a?(Array) && hash_keys.any?

  with do |redis|
    # Fetch an array of values for the supplied keys
    values = redis.hmget(cache_key(key), hash_keys)

    # Turn it back into a hash
    hash_keys.zip(values).to_h
  end
end