2016-12-19 39 views
0

假設我正在請求/products.json,它返回一個包含X個產品的JSON數組。每個都可在/product/[id].json。是否有可能讓午睡緩存該信息而不是對每個產品提出請求?還是必須將我的模型與資源分開存放?緩存來自單個請求的多個資源

回答

0

有這種這裏簡短的討論:

https://github.com/bustoutsolutions/siesta/issues/156

由於午睡目前存在的,每一個URL是一個單獨的緩存狀態單獨的資源。但是,您可以手動傳播從索引/表/搜索資源到相應的資源的變化對其個人成績:

childResource.addObserver(self) 
parentResource.addObserver(owner: self) { 
    if case .newData = $1 { 
    childResource.invalidate() 
    // Delayed refresh prevents redundant load if multiple 
    // children trigger a refresh on the same parent 
    DispatchQueue.main.async { 
     childResource.loadIfNeeded() 
    } 
    } 
} 

,對於更多的背景下,Github的問題的討論。