@@ -286,7 +286,7 @@ class SchemaController {
286286 this . data = { } ;
287287 this . perms = { } ;
288288 if ( clearCache ) {
289- this . _cache . reset ( ) ;
289+ this . _cache . clear ( ) ;
290290 }
291291 return this . getAllClasses ( clearCache )
292292 . then ( allSchemas => {
@@ -308,37 +308,39 @@ class SchemaController {
308308
309309 getAllClasses ( clearCache = false ) {
310310 if ( clearCache ) {
311- this . _cache . reset ( ) ;
311+ this . _cache . clear ( ) ;
312312 }
313- let allClasses = this . _cache . get ( ) ;
314- if ( allClasses && allClasses . length && ! clearCache ) {
315- return Promise . resolve ( allClasses ) ;
316- }
317- return this . _dbAdapter . getAllClasses ( )
318- . then ( allSchemas => allSchemas . map ( injectDefaultSchema ) )
319- . then ( allSchemas => {
320- this . _cache . set ( allSchemas ) ;
321- return allSchemas ;
322- } )
313+ return this . _cache . getAllClasses ( ) . then ( ( allClasses ) => {
314+ if ( allClasses && allClasses . length && ! clearCache ) {
315+ return Promise . resolve ( allClasses ) ;
316+ }
317+ return this . _dbAdapter . getAllClasses ( )
318+ . then ( allSchemas => allSchemas . map ( injectDefaultSchema ) )
319+ . then ( allSchemas => {
320+ this . _cache . setAllClasses ( allSchemas ) ;
321+ return allSchemas ;
322+ } )
323+ } ) ;
323324 }
324325
325326 getOneSchema ( className , allowVolatileClasses = false , clearCache ) {
326327 if ( clearCache ) {
327- this . _cache . reset ( ) ;
328- }
329- let cached = this . _cache . getOneSchema ( className ) ;
330- if ( cached && ! clearCache ) {
331- return Promise . resolve ( cached ) ;
328+ this . _cache . clear ( ) ;
332329 }
333- if ( allowVolatileClasses && volatileClasses . indexOf ( className ) > - 1 ) {
334- return Promise . resolve ( this . data [ className ] ) ;
335- }
336- return this . _dbAdapter . getClass ( className )
337- . then ( injectDefaultSchema )
338- . then ( ( result ) => {
339- this . _cache . setOneSchema ( className , result ) ;
340- return result ;
341- } )
330+ return this . _cache . getOneSchema ( className ) . then ( ( cached ) => {
331+ if ( cached && ! clearCache ) {
332+ return Promise . resolve ( cached ) ;
333+ }
334+ if ( allowVolatileClasses && volatileClasses . indexOf ( className ) > - 1 ) {
335+ return Promise . resolve ( this . data [ className ] ) ;
336+ }
337+ return this . _dbAdapter . getClass ( className )
338+ . then ( injectDefaultSchema )
339+ . then ( ( result ) => {
340+ this . _cache . setOneSchema ( className , result ) ;
341+ return result ;
342+ } ) ;
343+ } ) ;
342344 }
343345
344346 // Create a new class that includes the three default fields.
@@ -357,7 +359,7 @@ class SchemaController {
357359 return this . _dbAdapter . createClass ( className , convertSchemaToAdapterSchema ( { fields, classLevelPermissions, className } ) )
358360 . then ( convertAdapterSchemaToParseSchema )
359361 . then ( ( res ) => {
360- this . _cache . reset ( ) ;
362+ this . _cache . clear ( ) ;
361363 return res ;
362364 } )
363365 . catch ( error => {
@@ -569,7 +571,7 @@ class SchemaController {
569571 throw new Parse . Error ( Parse . Error . INVALID_JSON , `Could not add field ${ fieldName } ` ) ;
570572 }
571573 // Remove the cached schema
572- this . _cache . reset ( ) ;
574+ this . _cache . clear ( ) ;
573575 return this ;
574576 } ) ;
575577 } ) ;
@@ -613,7 +615,7 @@ class SchemaController {
613615 }
614616 return database . adapter . deleteFields ( className , schema , [ fieldName ] ) ;
615617 } ) . then ( ( ) => {
616- this . _cache . reset ( ) ;
618+ this . _cache . clear ( ) ;
617619 } ) ;
618620 }
619621
0 commit comments