Created
July 20, 2015 20:26
-
-
Save Casperhr/3d5e268a6a44e8b4204d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public function getAllForAPI() | |
| { | |
| // Lets try to look up in cache, hopefuly there is something there | |
| $contacts = Cache::get('contacts') | |
| // Is there something? | |
| if(!empty($contacts) { | |
| // Yep, lucky us, let's just return that instead of wasting time in DB | |
| return $contacts; | |
| } | |
| // Looking up in db | |
| $contacts = $this->orderBy('name', 'ASC')->get(); | |
| // Let's cache it, so next time we can skip this long lookup | |
| Cache::put('contacts', $contacts, 1440); | |
| return $contacts; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment