Fetch multiple keys efficiently, including available metadata such as CAS.
 If a block is given, yields key/data pairs one a time.  Data is an array:
 [value, cas_id]
 If no block is given, returns a hash of
   { 'key' => [value, cas_id] }
433666
def get_multi_cas(*keys)
      if block_given?
        get_multi_yielder(keys) {|*args| yield(*args)}
      else
        Hash.new.tap do |hash|
          get_multi_yielder(keys) {|k, data| hash[k] = data}
        end
      end
    end
567208
def data(self):
        
        d = {}
        for name in self.key_names:
            d[name] = self.__dict__.get(name, None)
        return d
516541
def deep_fetch(settings, *keys)
      key, *rest = keys
      value = settings.fetch(key.to_s, settings[key.to_sym])
      if value.nil? || rest.empty?
        value
      else
        deep_fetch(value, *rest)
      end
    end
407238
def getKey(k)
      return nil if k > @nitems || k <= 0
      pos = SIZEOF_BLOCK_HEADER + (SIZEOF_KEY * (k - 1))
      keydata = @data[pos, SIZEOF_KEY]
      data2key(keydata)
    end
272109
def fetch(key, default=nil)
      found_in = self_and_sub_collections.detect{ |c| c[key] }
      raise KeyError unless found_in
      found_in[key]
    end
1232671
def values(key)
      h = hash(key)

      hoff = @hashes[(h % 256)*2]
      hlen = @hashes[(h % 256)*2 + 1]

      return [] if hlen == 0
      off = (h / 256) % hlen

      vals = []

      # FIXME: Is this potentially an infinite loop (if full)?
      # Easy to avoid by exiting if off reaches the same value twice.

      while
          (slot = read(hoff + off * hashref_size .. hoff + off * hashref_size + hashref_size - 1)) &&
          (dslot = ary_unpack(slot,2)) && dslot[1] != 0

        if dslot[0] == h
          pos = dslot[1]

          rkey, value = read_entry(pos)
          if rkey == key
            vals << value
          end
        end
        off = (off + 1) % hlen
      end
      return vals
    end
797759
def fetch_key(key)
      string_key = key.to_s
      keys.detect { |k| k.to_s.casecmp(string_key) == 0 }
    end
1251477
def get(self, key):
        
        if not self.servers:
            return self.miss

        key = self._qualified_key(key)
        hashed_key = self.key_hasher(key)
        entry = self.client.get(hashed_key)

        if isinstance(entry, tuple) and len(entry) == 2:
            key_, result = entry
            if key_ == key:
                self.logger("HIT: %s", key)
                return result

        self.logger("MISS: %s", key)
        return self.miss
170952
def _get_keyid(keytype, scheme, key_value, hash_algorithm = 'sha256'):
  """"""

  # 'keyid' will be generated from an object conformant to KEY_SCHEMA,
  # which is the format Metadata files (e.g., root.json) store keys.
  # 'format_keyval_to_metadata()' returns the object needed by _get_keyid().
  key_meta = format_keyval_to_metadata(keytype, scheme, key_value, private=False)

  # Convert the key to JSON Canonical format, suitable for adding
  # to digest objects.
  key_update_data = securesystemslib.formats.encode_canonical(key_meta)

  # Create a digest object and call update(), using the JSON
  # canonical format of 'rskey_meta' as the update data.
  digest_object = securesystemslib.hash.digest(hash_algorithm)
  digest_object.update(key_update_data.encode('utf-8'))

  # 'keyid' becomes the hexadecimal representation of the hash.
  keyid = digest_object.hexdigest()

  return keyid
705484
def _get_val(record, keys):
    '''
    
    '''
    data = record
    for key in keys:
        if key in data:
            data = data[key]
        else:
            return None
    return data
337240
def _keys(result, key_ary, hash)
      hash.each do |key, value|
        key_ary << key
        result << "/#{key_ary.join('/')}"
        _keys(result, key_ary, value) if value.is_a?(Hash)
        key_ary.pop
      end
    end
66608
function get (data, key) {
  var keys = _keys(key);
  return keys && _get(data, keys);
}
1207384
def get(self, key, index=None):
        
        records = self.get_multi([key], index=index)

        try:
            return records[0][1]  # return the value from the key/value tuple
        except IndexError:
            return None
924401
def get_multi_yielder(keys)
      perform do
        return {} if keys.empty?
        ring.lock do
          begin
            groups = groups_for_keys(keys)
            if unfound_keys = groups.delete(nil)
              Dalli.logger.debug { "unable to get keys for #{unfound_keys.length} keys because no matching server was found" }
            end
            make_multi_get_requests(groups)

            servers = groups.keys
            return if servers.empty?
            servers = perform_multi_response_start(servers)

            start = Time.now
            while true
              # remove any dead servers
              servers.delete_if { |s| s.sock.nil? }
              break if servers.empty?

              # calculate remaining timeout
              elapsed = Time.now - start
              timeout = servers.first.options[:socket_timeout]
              time_left = (elapsed > timeout) ? 0 : timeout - elapsed

              sockets = servers.map(&:sock)
              readable, _ = IO.select(sockets, nil, nil, time_left)

              if readable.nil?
                # no response within timeout; abort pending connections
                servers.each do |server|
                  Dalli.logger.debug { "memcached at #{server.name} did not response within timeout" }
                  server.multi_response_abort
                end
                break

              else
                readable.each do |sock|
                  server = sock.server

                  begin
                    server.multi_response_nonblock.each_pair do |key, value_list|
                      yield key_without_namespace(key), value_list
                    end

                    if server.multi_response_completed?
                      servers.delete(server)
                    end
                  rescue NetworkError
                    servers.delete(server)
                  end
                end
              end
            end
          end
        end
      end
    end
1275412
def get_keys_for(self, value):
        
        if callable(value):
            return value(self)
        hash_value = self.get_hash_for(value)
        return self._index[hash_value][:]
188026
def keys(self, **kwargs):
        
        warnings.warn('Use of `rel.fetch.keys()` notation is deprecated. '
                      'Please use `rel.fetch("KEY")` or `rel.fetch(dj.key)` for equivalent result', stacklevel=2)
        yield from self._expression.proj().fetch(as_dict=True, **kwargs)
495530
def get(key)
      if @items.include?(key)
        @list.each_index do |i|
          if @list[i] == key
            @list.delete_at(i)
            break
          end
        end
        @list.push(key)
        @items[key]
      else
        return nil unless block_given?
         self[key] = yield
      end
    end