mirror of
https://github.com/minio/minio.git
synced 2025-11-09 05:34:56 -05:00
Add disk based edge caching support. (#5182)
This PR adds disk based edge caching support for minio server. Cache settings can be configured in config.json to take list of disk drives, cache expiry in days and file patterns to exclude from cache or via environment variables MINIO_CACHE_DRIVES, MINIO_CACHE_EXCLUDE and MINIO_CACHE_EXPIRY Design assumes that Atime support is enabled and the list of cache drives is fixed. - Objects are cached on both GET and PUT/POST operations. - Expiry is used as hint to evict older entries from cache, or if 80% of cache capacity is filled. - When object storage backend is down, GET, LIST and HEAD operations fetch object seamlessly from cache. Current Limitations - Bucket policies are not cached, so anonymous operations are not supported in offline mode. - Objects are distributed using deterministic hashing among list of cache drives specified.If one or more drives go offline, or cache drive configuration is altered - performance could degrade to linear lookup. Fixes #4026
This commit is contained in:
@@ -545,6 +545,14 @@ func resetGlobalHealState() {
|
||||
}
|
||||
}
|
||||
}
|
||||
func resetGlobalCacheEnvs() {
|
||||
globalIsDiskCacheEnabled = false
|
||||
}
|
||||
|
||||
// sets globalObjectAPI to `nil`.
|
||||
func resetGlobalCacheObjectAPI() {
|
||||
globalCacheObjectAPI = nil
|
||||
}
|
||||
|
||||
// Resets all the globals used modified in tests.
|
||||
// Resetting ensures that the changes made to globals by one test doesn't affect others.
|
||||
@@ -567,6 +575,10 @@ func resetTestGlobals() {
|
||||
resetGlobalStorageEnvs()
|
||||
// Reset global heal state
|
||||
resetGlobalHealState()
|
||||
//Reset global disk cache flags
|
||||
resetGlobalCacheEnvs()
|
||||
//set globalCacheObjectAPI to nil
|
||||
resetGlobalCacheObjectAPI()
|
||||
}
|
||||
|
||||
// Configure the server for the test run.
|
||||
@@ -2199,13 +2211,17 @@ func registerAPIFunctions(muxRouter *router.Router, objLayer ObjectLayer, apiFun
|
||||
bucketRouter := apiRouter.PathPrefix("/{bucket}").Subrouter()
|
||||
|
||||
// All object storage operations are registered as HTTP handlers on `objectAPIHandlers`.
|
||||
// When the handlers get a HTTP request they use the underlyting ObjectLayer to perform operations.
|
||||
// When the handlers get a HTTP request they use the underlying ObjectLayer to perform operations.
|
||||
globalObjLayerMutex.Lock()
|
||||
globalObjectAPI = objLayer
|
||||
globalObjLayerMutex.Unlock()
|
||||
|
||||
// When cache is enabled, Put and Get operations are passed
|
||||
// to underlying cache layer to manage object layer operation and disk caching
|
||||
// operation
|
||||
api := objectAPIHandlers{
|
||||
ObjectAPI: newObjectLayerFn,
|
||||
CacheAPI: newCacheObjectsFn,
|
||||
}
|
||||
|
||||
// Register ListBuckets handler.
|
||||
|
||||
Reference in New Issue
Block a user