Created
August 2, 2010 16:14
-
-
Save aarongustafson/504869 to your computer and use it in GitHub Desktop.
This file contains 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
// create a Squirrel instance | |
var $S = new Squirrel( 'scale-song' ); | |
// write a value to the cache | |
$S.write( 'doe', 'ray' ); | |
// read it back | |
$S.read( 'doe' ); // 'ray' | |
// write a value to a sub-cache | |
$S.write( 'song', 'doe', 'a dear, a female dear' ); | |
// read back the original value | |
$S.read( 'doe' ); // 'ray' | |
// read back the sub-cached value | |
$S.read( 'song', 'doe' ); // 'a dear, a female dear' | |
// removing a single property from the sub-cache | |
$S.remove( 'song', 'doe' ); | |
// try to read the sub-cached value | |
$S.read( 'song', 'doe' ); // null | |
// read the root value | |
$S.read( 'doe' ); // 'ray' | |
// add some more content to the sub-cache | |
$S.write( 'song', 'doe', 'a dear, a female dear' ); | |
$S.write( 'song', 'ray', 'a drop of golden sun' ); | |
// clear the whole sub-cache | |
$S.clear( 'song' ); | |
// check that it's been cleared | |
$S.read( 'song', 'doe' ); // null | |
$S.read( 'song', 'ray' ); // null | |
// check that the root value's still instact | |
$S.read( 'doe' ); // 'ray' | |
// remove a property form the main cache | |
$S.remove( 'doe' ); | |
// check it's value | |
$S.read( 'doe' ); // null | |
// write a bit more data in the root and in a sub-cache | |
$S.write( 'doe', 'ray' ); | |
$S.write( 'song', 'doe', 'a dear, a female dear' ); | |
$S.write( 'song', 'ray', 'a drop of golden sun' ); | |
// clear the whole cache | |
$S.clear(); | |
// check it's all gone | |
$S.read( 'song', 'doe' ); // null | |
$S.read( 'song', 'ray' ); // null | |
$S.read( 'doe' ); // null |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment