Permalink
Browse files

Merge branch 'live-docs' of github.com:yui/yui3 into live-docs

  • Loading branch information...
2 parents e703ef0 + 861abc1 commit 132588f107228cec5c04269db791fa252d2218fd @tilomitra tilomitra committed Jan 9, 2013
Showing with 15 additions and 32 deletions.
  1. +0 −21 src/cache/docs/cache-basic.mustache
  2. +15 −11 src/cache/docs/partials/cache-basic-source.mustache
@@ -6,27 +6,6 @@
{{>cache-basic-source}}
</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>
```
@@ -30,37 +30,41 @@
<div id="out">(cache results here)</div>
<script>
-YUI().use("node", "datatype-number", "cache-base" ,function (Y) {
- var cache = new Y.Cache(),
- out = Y.one('#out');
-
+YUI().use("node", "datatype-number", "cache-base", "escape" , function (Y) {
+ var cache = new Y.Cache(),
+ out = Y.one('#out'),
+ escape = Y.Escape.html;
+
Y.on("click", function(e){
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");
-
+
Y.on("click", function(e){
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");
Y.on("click", function(e){
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");
Y.on("click", function(e){
cache.add(Y.one("#demo_addKey").get("value"), Y.one("#demo_addValue").get("value"));
var msg = cache.get("max") ?
"Value cached. Cache size is now " + cache.get("size") + "." :
"Cache max is " + cache.get("max") + ". Value not cached."
- out.setHTML(msg);
+ out.setHTML(escape(msg)); // Escape user input for example.
}, "#demo_add");
Y.on("click", function(e){
var entry = cache.retrieve(Y.one("#demo_retrieveKey").get("value")),
- output = entry ? entry.response : "Value not cached.";
- out.setHTML(output);
+ msg = entry ? entry.response : "Value not cached.";
+ out.setHTML(escape(msg)); // Escape user input for example.
}, "#demo_retrieve");
Y.on("click", function(e){

0 comments on commit 132588f

Please sign in to comment.