Skip to content

Instantly share code, notes, and snippets.

@karptonite
Created October 22, 2013 00:52
Show Gist options
  • Save karptonite/7093489 to your computer and use it in GitHub Desktop.
Save karptonite/7093489 to your computer and use it in GitHub Desktop.
Use of Cache tags
<?php
//Intended use of Tags
//an ordered array of tag names
$tags = array( 'people', 'authors' );
//to store
Cache::tags( $tags )->put('John', $john);
//to access
//note that you need the whole list of tags to access
Cache::tags( $tags )->get('John');
//Flushing either tag will flush John's cache.
//to flush just the authors
Cache::tag( 'authors' )->flush();
//to flush all the people
Cache::tag( 'people' )->flush();
//to flush multiple tags
Cache::tags( $tags )->flush();
//section remains an alias of tag, and works just like the old section
Cache::section('people')->put('John', $john);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment