Try to retrieve schema from all schemas cache if not found in individual cache (#2912)
* Try to get schema from main schema if not found in single schema * Add newline * Add missing return * Add missing done to tests
This commit is contained in:
committed by
Florent Vilmart
parent
af55cd1efb
commit
151bea25ee
@@ -50,7 +50,21 @@ export default class SchemaCache {
|
||||
if (!this.ttl) {
|
||||
return Promise.resolve(null);
|
||||
}
|
||||
return this.cache.get(this.prefix+className);
|
||||
return this.cache.get(this.prefix+className).then((schema) => {
|
||||
if (schema) {
|
||||
return Promise.resolve(schema);
|
||||
}
|
||||
return this.cache.get(this.prefix+MAIN_SCHEMA).then((cachedSchemas) => {
|
||||
cachedSchemas = cachedSchemas || [];
|
||||
schema = cachedSchemas.find((cachedSchema) => {
|
||||
return cachedSchema.className === className;
|
||||
});
|
||||
if (schema) {
|
||||
return Promise.resolve(schema);
|
||||
}
|
||||
return Promise.resolve(null);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
clear() {
|
||||
|
||||
Reference in New Issue
Block a user