Class: LinkageCacheStore Private

Inherits:
CacheStore show all
Defined in:
linkage_cache_store.rb

Overview

This class is part of a private API. This class may only be used in the Homebrew/brew repository. Third parties should avoid using this class if possible, as it may be removed or changed without warning.

LinkageCacheStore provides methods to fetch and mutate linkage-specific data used by the brew linkage command.

Instance Method Summary collapse

Constructor Details

#initialize(keg_path, database) ⇒ void

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.

Parameters:



15
16
17
18
# File 'linkage_cache_store.rb', line 15

def initialize(keg_path, database)
  @keg_path = T.let(keg_path, String)
  super(database)
end

Instance Method Details

#delete!void

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.

This method returns an undefined value.

Delete the keg from the LinkageCacheStore.



66
67
68
# File 'linkage_cache_store.rb', line 66

def delete!
  database.delete(@keg_path)
end

#fetch(type) ⇒ T.untyped

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.

Parameters:

Returns:

  • (T.untyped)

Raises:

  • (TypeError)

    error if the type is not in HASH_LINKAGE_TYPES



50
51
52
53
54
55
56
57
58
59
60
# File 'linkage_cache_store.rb', line 50

def fetch(type)
  unless HASH_LINKAGE_TYPES.include?(type)
    raise TypeError, <<~EOS
      Can't fetch types that are not defined for the linkage store
    EOS
  end

  return {} unless keg_exists?

  fetch_hash_values(type)
end

#keg_exists?Boolean

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.

Returns true if the database has any value for the current keg_path.

Returns:

  • (Boolean)


24
25
26
# File 'linkage_cache_store.rb', line 24

def keg_exists?
  !database.get(@keg_path).nil?
end

#update!(hash_values) ⇒ void

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.

This method returns an undefined value.

Inserts dylib-related information into the cache if it does not exist or updates data into the linkage cache if it does exist.

Parameters:

  • hash_values (Hash{Symbol => T.anything})

    hash containing KVPs of { :type => Hash }



34
35
36
37
38
39
40
41
42
43
44
# File 'linkage_cache_store.rb', line 34

def update!(hash_values)
  hash_values.each_key do |type|
    next if HASH_LINKAGE_TYPES.include?(type)

    raise TypeError, <<~EOS
      Can't update types that are not defined for the linkage store
    EOS
  end

  database.set @keg_path, hash_values
end