async function squads() {
	
	try {
    	
        let expiredDate = new Date();
	        expiredDate.setHours(expiredDate.getHours() - squadCooldown);
		
		/** Get player from cache */
		let squads = await cache.get('swapi', 'squads', {updated:{ $gte:expiredDate.getTime() }});

		/** Check if existance and expiration */
		if( !squads || !squads[0] ) { 
		
			/** If not found or expired, fetch new from API and save to cache */
			squads = await swgoh.fetchSquads({});
			
			if( !squads ) { throw new Error('Error fetching zeta recommendations'); } 
			
			squads = await cache.put('swapi', 'squads', {}, squads);

		} else {		
		    squads = squads[0];
		}

		return squads;
		
	} catch(e) { 
		throw e; 
	}    		

}
/**
 *  Fetch squad recommendations from cache, and sync if necessary
 * 
 */
Fetch squad recommendations from cache, and sync if necessary
Fetch squad recommendations from cache and sync if necessary
async function squads() {
	try {
        let expiredDate = new Date();
	        expiredDate.setHours(expiredDate.getHours() - squadCooldown);
		let squads = await cache.get('swapi', 'squads', {updated:{ $gte:expiredDate.getTime() }});
		if( !squads || !squads[0] ) { 
			squads = await swgoh.fetchSquads({});
			if( !squads ) { throw new Error('Error fetching zeta recommendations'); } 
			squads = await cache.put('swapi', 'squads', {}, squads);
		} else {		
		    squads = squads[0];
		}
		return squads;
	} catch(e) { 
		throw e; 
	}    		
}
async function squads ( ) { try { let expiredDate = new Date ( ) ; expiredDate . setHours ( expiredDate . getHours ( ) - squadCooldown ) ; let squads = await cache . get ( 'swapi' , 'squads' , { updated : { $gte : expiredDate . getTime ( ) } } ) ; if ( ! squads || ! squads [ 0 ] ) { squads = await swgoh . fetchSquads ( { } ) ; if ( ! squads ) { throw new Error ( 'Error fetching zeta recommendations' ) ; } squads = await cache . put ( 'swapi' , 'squads' , { } , squads ) ; } else { squads = squads [ 0 ] ; } return squads ; } catch ( e ) { throw e ; } }
Fetch squad recommendations from cache, and sync if necessary
Fetch squad recommendations from cache and sync if necessary
/** Get player from cache */ /** Check if existance and expiration */ /** If not found or expired, fetch new from API and save to cache */