The Gallery is deprecated. No new Gallery components may be submitted, and modifying existing components is disabled. For more information please read the Gallery Deprecation blog post. This is a static snapshot of the Gallery for archive purposes.
See 50 more by this user. Created: 03/8/12
Last CDN Push: 05/23/12
Build Tag: gallery-2012.05.23-19-56
Project: YUI 3
License: YUI BSD
YUI Version: 3.5.1
Free for use.
Cache which drops least used items to satisfy a user-defined criterion, e.g., total size or number of items. This can be used as the data store for Expiration Cache (http://yuilibrary.com/gallery/show/expiration-cache) to limit both key lifetime and total memory.
Example of creating different types of MRU caches.
<script src="http://yui.yahooapis.com/3.5.1/build/yui/yui-min.js"></script>
YUI({
//Last Gallery Build of this module
gallery: 'gallery-2012.05.23-19-56'
}).use('gallery-mru-cache', function(Y)
{
// create a cache which holds up to 500M
var size_cache = new Y.MRUCache(
{
metric: function(value)
{
return value.length;
},
limit: Math.pow(2, 29) // 500M
});
size_cache.put('foo', 'bar');
var data = size_cache.get('foo');
// create a cache which holds up to 1000 items
var count_cache = new Y.MRUCache(
{
metric: function(value)
{
return +1;
},
limit: 1000
});
});
All code on this site is licensed under the BSD License unless stated otherwise.