Class: LinkageCacheStore

Inherits:
CacheStore show all
Defined in:
brew/Library/Homebrew/linkage_cache_store.rb

Overview

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) ⇒ nil

Parameters:



14
15
16
17
# File 'brew/Library/Homebrew/linkage_cache_store.rb', line 14

def initialize(keg_path, database)
  @keg_path = keg_path
  super(database)
end

Instance Method Details

#delete!nil

Delete the keg from the LinkageCacheStore

Returns:

  • (nil)


61
62
63
# File 'brew/Library/Homebrew/linkage_cache_store.rb', line 61

def delete!
  database.delete(@keg_path)
end

#fetch(type) ⇒ Hash

Parameters:

  • type (Symbol)

    the type to fetch from the LinkageCacheStore

Returns:

  • (Hash)

Raises:

  • (TypeError)

    error if the type is not in HASH_LINKAGE_TYPES



46
47
48
49
50
51
52
53
54
55
56
# File 'brew/Library/Homebrew/linkage_cache_store.rb', line 46

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

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

Returns:

  • (Boolean)


22
23
24
# File 'brew/Library/Homebrew/linkage_cache_store.rb', line 22

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

#update!(hash_values) ⇒ nil

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)

    hash containing KVPs of { :type => Hash }

Returns:

  • (nil)


31
32
33
34
35
36
37
38
39
40
41
# File 'brew/Library/Homebrew/linkage_cache_store.rb', line 31

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