Documentation ¶
Overview ¶
Package simplecache provides support for reading Chromium simple cache. http://www.chromium.org/developers/design-documents/network-stack/disk-cache/very-simple-backend
Example ¶
Example gets an entry from the cache and prints it to stdout.
package main import ( "fmt" "image/png" "log" "github.com/schorlet/simplecache" ) func main() { entry, err := simplecache.Get("https://golang.org/doc/gopher/pkg.png", "testdata") if err != nil { log.Fatal(err) } fmt.Println(entry.URL) header, err := entry.Header() if err != nil { log.Fatal(err) } for _, key := range []string{"Status", "Content-Length", "Content-Type"} { fmt.Printf("%s: %s\n", key, header.Get(key)) } body, err := entry.Body() if err != nil { log.Fatal(err) } defer body.Close() config, err := png.DecodeConfig(body) if err != nil { log.Fatal(err) } fmt.Printf("PNG image data, %d x %d\n", config.Width, config.Height) }
Output: https://golang.org/doc/gopher/pkg.png Status: 200 Content-Length: 5409 Content-Type: image/png PNG image data, 83 x 120
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func URLs ¶
URLs returns all the URLs currently stored in the cache.
On linux, valid cache paths are:
~/.cache/chromium/Default/Cache ~/.cache/chromium/Default/Media Cache
URLs reads the files named "path/index" and "path/index-dir/the-real-index" and every entry files named "path/hash(url)_0" where hash is read from the-real-index file.
An error is returned if the format of the index files is unexpected.
Types ¶
type Entry ¶
type Entry struct { URL string // contains filtered or unexported fields }
Entry represents a HTTP response as stored in the cache. Each entry is stored in a file named "path/hash(url)_0".
func Get ¶
Get returns the Entry for the specified URL. An error is returned if the format of the entry does not match the one expected.
Directories ¶
Path | Synopsis |
---|---|
cmd
|
|
simplecache
Command simplecache helps reading chromium simple cache v6 or v7.
|
Command simplecache helps reading chromium simple cache v6 or v7. |