/*    HTTP Host:  b.static.ak.fbcdn.net                                        */
/*    Generated:  January 26th 2010 9:24:12 AM PST                             */
/*      Machine:  10.16.140.103                                                */
/*       Source:  Local Cache                                                  */
/*     Location:  rsrc:4:e9v2oufw                                              */
/*       Locale:  nu_ll                                                        */
/*         Path:  js/lib/util/cache_storage.js                                 */

if (window.CavalryLogger) { CavalryLogger.start_js(["js\/lib\/util\/cache_storage.js"]); }

_PERSISTENT_BACKENDS={localstorage:LocalStorage};function LocalStorage(){this._store=window.localStorage;}LocalStorage.available=function(){return window.localStorage?true:false;};copy_properties(LocalStorage.prototype,{keys:function(){var b=[];for(var a=0;a<this._store.length;a++)b.push(this._store.key(a));return b;},get:function(a){return this._store.getItem(a);},set:function(a,b){this._store.setItem(a,b);},remove:function(a){this._store.removeItem(a);},clear:function(){this._store.clear();}});function CacheStorage(d,b){this._key_prefix=b||'_cs_';this._magic_prefix='_@_';if(d=='AUTO')for(var c in _PERSISTENT_BACKENDS){var a=_PERSISTENT_BACKENDS[c];if(a.available()){d=c;break;}}if(d)if(!_PERSISTENT_BACKENDS[d]){this._backend=null;}else this._backend=new _PERSISTENT_BACKENDS[d]();this._memcache={};}copy_properties(CacheStorage.prototype,{keys:function(){var d=[];if(this._backend){var a=this._backend.keys();for(var b=0;b<a.length;b++)if(a[b].substr(0,this._key_prefix.length)==this._key_prefix)d.push(a[b].substr(this._key_prefix.length));return d;}for(var c in this._memcache)d.push(c);return d;},set:function(b,a){this._memcache[b]=a;if(this._backend){if(typeof a=='string'){a=this._magic_prefix+a;}else a=JSON.encode(a);this._backend.set(this._key_prefix+b,a);}},get:function(b,c){if(this._memcache[b]!==undefined)return this._memcache[b];var d=undefined;if(this._backend){var d=this._backend.get(this._key_prefix+b);if(d!==null){if(d.substr(0,this._magic_prefix.length)==this._magic_prefix){d=d.substr(this._magic_prefix.length);}else d=JSON.decode(d);this._memcache[b]=d;}else d=undefined;}if(d===undefined&&c!==undefined){d=c;this._memcache[b]=d;if(this._backend){if(typeof d=='string'){var a=this._magic_prefix+d;}else var a=JSON.encode(d);this._backend.set(this._key_prefix+b,a);}}return d;},remove:function(a){delete this._memcache[a];if(this._backend)this._backend.remove(this._key_prefix+a);}});

if (window.Bootloader) { Bootloader.done(["js\/lib\/util\/cache_storage.js"]); }