Skip to content

Commit

Permalink
Merge branch 'live-docs' into dev-master
Browse files Browse the repository at this point in the history
  • Loading branch information
ericf committed Jan 9, 2013
2 parents 611cbee + 861abc1 commit e639e49
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 32 deletions.
21 changes: 0 additions & 21 deletions src/cache/docs/cache-basic.mustache
Expand Up @@ -6,27 +6,6 @@
{{>cache-basic-source}} {{>cache-basic-source}}
</div> </div>


```
YUI().use("cache-base", function(Y) {
// Configure Cache maximum size, expires in the constructor
var cache = new Y.Cache({max:5, expires:3600000});

// Add entries to the Cache
cache.add("key1", "value1");
cache.add("key2", "value2");

// Retrieve a cached entry
var cachedentry = cache.retrieve("key1");

// Cached entry is an object with a request property and a response property
alert("cached key: " + cachedentry.request +
"/cached value: " + cachedentry.response);

// Flush the cache
cache.flush();
});
```

<h2>Complete Example Source</h2> <h2>Complete Example Source</h2>


``` ```
Expand Down
26 changes: 15 additions & 11 deletions src/cache/docs/partials/cache-basic-source.mustache
Expand Up @@ -30,37 +30,41 @@
<div id="out">(cache results here)</div> <div id="out">(cache results here)</div>


<script> <script>
YUI().use("node", "datatype-number", "cache-base" ,function (Y) { YUI().use("node", "datatype-number", "cache-base", "escape" , function (Y) {
var cache = new Y.Cache(), var cache = new Y.Cache(),
out = Y.one('#out'); out = Y.one('#out'),
escape = Y.Escape.html;
Y.on("click", function(e){ Y.on("click", function(e){
cache.set("max", Y.DataType.Number.parse(Y.one("#demo_max").get("value"))); cache.set("max", Y.DataType.Number.parse(Y.one("#demo_max").get("value")));
out.setHTML("Cache max set to " + cache.get("max") + "."); var msg = "Cache max set to " + cache.get("max") + ".";
out.setHTML(escape(msg)); // Escape user input for example.
}, "#demo_setMax"); }, "#demo_setMax");
Y.on("click", function(e){ Y.on("click", function(e){
cache.set("uniqueKeys", Y.one("#demo_setUniqueKeys").get("checked")); cache.set("uniqueKeys", Y.one("#demo_setUniqueKeys").get("checked"));
out.setHTML("Cache uniqueKeys set to " + cache.get("uniqueKeys") + "."); var msg = "Cache uniqueKeys set to " + cache.get("uniqueKeys") + ".";
out.setHTML(escape(msg)); // Escape user input for example.
}, "#demo_setUniqueKeys"); }, "#demo_setUniqueKeys");
Y.on("click", function(e){ Y.on("click", function(e){
cache.set("expires", Y.DataType.Number.parse(Y.one("#demo_expires").get("value"))); cache.set("expires", Y.DataType.Number.parse(Y.one("#demo_expires").get("value")));
out.setHTML("Cache \"expires\" set to " + cache.get("expires") + "."); var msg = "Cache \"expires\" set to " + cache.get("expires") + ".";
out.setHTML(escape(msg)); // Escape user input for example.
}, "#demo_setExpires"); }, "#demo_setExpires");
Y.on("click", function(e){ Y.on("click", function(e){
cache.add(Y.one("#demo_addKey").get("value"), Y.one("#demo_addValue").get("value")); cache.add(Y.one("#demo_addKey").get("value"), Y.one("#demo_addValue").get("value"));
var msg = cache.get("max") ? var msg = cache.get("max") ?
"Value cached. Cache size is now " + cache.get("size") + "." : "Value cached. Cache size is now " + cache.get("size") + "." :
"Cache max is " + cache.get("max") + ". Value not cached." "Cache max is " + cache.get("max") + ". Value not cached."
out.setHTML(msg); out.setHTML(escape(msg)); // Escape user input for example.
}, "#demo_add"); }, "#demo_add");
Y.on("click", function(e){ Y.on("click", function(e){
var entry = cache.retrieve(Y.one("#demo_retrieveKey").get("value")), var entry = cache.retrieve(Y.one("#demo_retrieveKey").get("value")),
output = entry ? entry.response : "Value not cached."; msg = entry ? entry.response : "Value not cached.";
out.setHTML(output); out.setHTML(escape(msg)); // Escape user input for example.
}, "#demo_retrieve"); }, "#demo_retrieve");
Y.on("click", function(e){ Y.on("click", function(e){
Expand Down

0 comments on commit e639e49

Please sign in to comment.