Grab value from cache when mapping

This commit is contained in:
Chris Roberts 2022-02-07 14:26:00 -08:00 committed by Paul Hinze
parent 58568b06fa
commit 14895eded1
No known key found for this signature in database
GPG Key ID: B69DEDF2D55501C0
5 changed files with 8 additions and 10 deletions

View File

@ -31,8 +31,8 @@ module VagrantPlugins
end
def converter(proto, broker, cacher)
cid = proto.addr.to_s if proto.addr.to_s != ""
return cacher[cid] if cid && cacher.registered?(cid)
cid = proto.target.to_s if proto.target.to_s != ""
return cacher[cid].value if cid && cacher.registered?(cid)
project = Client::Basis.load(proto, broker: broker)
cacher[cid] = project if cid

View File

@ -15,7 +15,7 @@ module VagrantPlugins
def converter(project, ui, cacher)
cid = project.resource_id
return cacher[cid] if cacher.registered?(cid)
return cacher[cid].value if cacher.registered?(cid)
logger.warn("cache miss for environment with project resource id #{cid} cache=#{cacher} !!")
env = Vagrant::Environment.new(ui: ui, client: project)
cacher[cid] = env
@ -37,7 +37,7 @@ module VagrantPlugins
def converter(project, cacher, mapper)
cid = project.resource_id
return cacher[cid] if cacher.registered?(cid)
return cacher[cid].value if cacher.registered?(cid)
logger.warn("cache miss for environment with project resource id #{cid} cache=#{cacher}")
ui = mapper.map(project, to: Vagrant::UI::Remote)
env = Vagrant::Environment.new(client: project, ui: ui)

View File

@ -49,8 +49,8 @@ module VagrantPlugins
end
def converter(proto, broker, cacher)
cid = proto.addr.to_s if proto.addr.to_s != ""
return cacher[cid] if cid && cacher.registered?(cid)
cid = proto.target.to_s if proto.target.to_s != ""
return cacher[cid].value if cid && cacher.registered?(cid)
project = Client::Project.load(proto, broker: broker)
cacher[cid] = project if cid

View File

@ -41,8 +41,8 @@ module VagrantPlugins
end
def converter(proto, broker, cacher)
cid = proto.addr.to_s if proto.addr.to_s != ""
return cacher[cid] if cid && cacher.registered?(cid)
cid = proto.target.to_s if proto.target.to_s != ""
return cacher[cid].value if cid && cacher.registered?(cid)
project = Client::SyncedFolder.load(proto, broker: broker)
cacher[cid] = project if cid

View File

@ -7,7 +7,6 @@ module VagrantPlugins
include Mutex_m
class Entry
include Mutex_m
attr_reader :value
def initialize(value)
@ -16,7 +15,6 @@ module VagrantPlugins
end
def value
raise "Entry must be locked to access value" if !mu_locked?
@value
end
end