mirror of
https://github.com/pgsty/minio.git
synced 2026-07-22 21:50:22 +03:00
XL: GetObject caching implemented for XL. (#2017)
The object cache implementation is XL cache, which defaults to 8GB worth of read cache. Currently GetObject() transparently writes to this cache upon first client read and then subsequently serves reads from the same cache. Currently expiration is not implemented.
This commit is contained in:
+7
-5
@@ -115,6 +115,7 @@ func (api objectAPIHandlers) GetObjectHandler(w http.ResponseWriter, r *http.Req
|
||||
return
|
||||
}
|
||||
|
||||
// Caculate the http Range.
|
||||
var hrange *httpRange
|
||||
hrange, err = getRequestedRange(r.Header.Get("Range"), objInfo.Size)
|
||||
if err != nil {
|
||||
@@ -144,22 +145,23 @@ func (api objectAPIHandlers) GetObjectHandler(w http.ResponseWriter, r *http.Req
|
||||
if length == 0 {
|
||||
length = objInfo.Size - startOffset
|
||||
}
|
||||
|
||||
// Reads the object at startOffset and writes to mw.
|
||||
if err := api.ObjectAPI.GetObject(bucket, object, startOffset, length, w); err != nil {
|
||||
errorIf(err, "Writing to client failed.")
|
||||
errorIf(err, "Unable to write to client.")
|
||||
// Do not send error response here, client would have already died.
|
||||
return
|
||||
}
|
||||
// Success.
|
||||
}
|
||||
|
||||
var unixEpochTime = time.Unix(0, 0)
|
||||
|
||||
// checkLastModified implements If-Modified-Since and
|
||||
// If-Unmodified-Since checks.
|
||||
//
|
||||
// modtime is the modification time of the resource to be served, or
|
||||
// IsZero(). return value is whether this request is now complete.
|
||||
func checkLastModified(w http.ResponseWriter, r *http.Request, modtime time.Time) bool {
|
||||
if modtime.IsZero() || modtime.Equal(unixEpochTime) {
|
||||
if modtime.IsZero() || modtime.Equal(time.Unix(0, 0)) {
|
||||
// If the object doesn't have a modtime (IsZero), or the modtime
|
||||
// is obviously garbage (Unix time == 0), then ignore modtimes
|
||||
// and don't process the If-Modified-Since header.
|
||||
@@ -452,7 +454,7 @@ func (api objectAPIHandlers) CopyObjectHandler(w http.ResponseWriter, r *http.Re
|
||||
// modtime is the modification time of the resource to be served, or
|
||||
// IsZero(). return value is whether this request is now complete.
|
||||
func checkCopySourceLastModified(w http.ResponseWriter, r *http.Request, modtime time.Time) bool {
|
||||
if modtime.IsZero() || modtime.Equal(unixEpochTime) {
|
||||
if modtime.IsZero() || modtime.Equal(time.Unix(0, 0)) {
|
||||
// If the object doesn't have a modtime (IsZero), or the modtime
|
||||
// is obviously garbage (Unix time == 0), then ignore modtimes
|
||||
// and don't process the If-Modified-Since header.
|
||||
|
||||
Reference in New Issue
Block a user