DougTitle: Hello World ResourceStore
Gears ResourceStore Demo
This page demonstrates basic usage of ResourceStore.
Things you can do:
- Press the 'CreateStore' button to create a resource store to contain captured resources.
- Press the 'Capture' button to capture this page.
- Unplug the network cable and verify that you can still access this page.
- Delete your browser cache and verify that you can still access this page.
- Press the 'Uncapture' button to remove the page from the ResourceStore. Verify that you can no longer access the page offline.
- Press the 'RemoveStore' button to remove the resource store.
On Nov 8, 2008, at 6:18 PM, Dave wrote:
Makes sense...and then presumably I'd just set the src attribute of the Image object to my special URL? Keeping a separate array so I know which things to free seems pretty straightforward. The only problem is that this blob technique is new enough not to be in the documentation yet, so (particularly as someone new to Gears) I'm not sure how to "invent yourself some (hopefully) unique URL, and then request that the LocalServer cache it, giving it the blob." Can I trouble you for a code snippet or two (including how to free it up if that's not straightforward)? Thanks! On Nov 8, 2:35 pm, Douglas Mayle <[EMAIL PROTECTED]> wrote:captureBlob requires the nightlies... You can search in this group tofind a reference. You invent yourself some (hopefully) unique URL, and then request that the LocalServer cache it, giving it the blob. Once you've done that, you can access like any other remote document, except that it doesn't need a request to the remote server. Unfortunately, LocalServer doesn't give you any way to enumerate the captured URLs, so you'll have to keep track of that yourself, perhaps with a database. To make it easier, you can keep them grouped in silos by using the named stores. On Nov 8, 2008, at 2:37 PM, Dave wrote:I don't see anything about captureBlob() in the API docs for Gears. Would I need do download a nightly or something to get it? What additional step is required to create a reference, or does captureBlob() keep one?More generally, does anyone have an example?Also, how will I know when disk space is getting full and clean-up isrequired? Or do I just need to guess based on average image size and number?On Nov 8, 1:21 am, Khookie <[EMAIL PROTECTED]> wrote:Chris,In that case I would just fetch the Blobs, and keep a reference so they don't get garbage collected.Wouldn't the blobs need to be captured with ResourceStore.captureBlob(...) before you can view them as images through DOM manipulation or a straight <img> tag?And also, I assume that anything captured with captureBlob(...) can beremoved with remove(...) when the blob isn't required anymore? Thatway, Dave can create his image caching slideshow.CheersChrisOn Nov 8, 1:59 pm, Chris Prince <[EMAIL PROTECTED]> wrote:Thanks. So is there a better way to do this in Gears? Again, I'm running a changing slideshow with lots of images in it. The page won't refresh very often but will pull in new images periodically. Keeping them all in memory is probably a bad idea so I want to cache them on disk...but as that cache gets big I'll need to prune itOh, so you plan on being connected? And you are mostly interested in caching, rather than persisting the data across browser sessions?In that case I would just fetch the Blobs, and keep a reference so they don't get garbage collected.For in-session caching, I wouldn't worry too much about whether therepresentation is in-memory or on-disk. You should be able to rely on Gears and the operating system to Be Smart About It (tm).FWIW, there was a discussion about automatically spilling large Blobs to disk.http://groups.google.com/group/gears-eng/msg/d589bd81968561eeAnd even without that, the OS will spill to the user's paging file as needed. You should get the effect you want today.Are you not seeing that?--Chris
