| 86 | } |
| 87 | |
| 88 | func newFromConfig(ld blobserver.Loader, config jsonconfig.Obj) (blobserver.Storage, error) { |
| 89 | var ( |
| 90 | origin = config.RequiredString("origin") |
| 91 | cache = config.RequiredString("cache") |
| 92 | maxCacheBytes = config.OptionalInt64("maxCacheBytes", 512<<20) |
| 93 | ) |
| 94 | if err := config.Validate(); err != nil { |
| 95 | return nil, err |
| 96 | } |
| 97 | cacheSto, err := ld.GetStorage(cache) |
| 98 | if err != nil { |
| 99 | return nil, err |
| 100 | } |
| 101 | originSto, err := ld.GetStorage(origin) |
| 102 | if err != nil { |
| 103 | return nil, err |
| 104 | } |
| 105 | return New(maxCacheBytes, cacheSto, originSto), nil |
| 106 | } |
| 107 | |
| 108 | // must hold sto.mu. |
| 109 | // Reports whether an item was removed. |