code: function(obj) {
          if (window.localStorage) {
              var tile = obj.tile;
              try {
                  var canvasContext = tile.getCanvasContext();
                  if (canvasContext) {
                      var urlMap = OpenLayers.Control.CacheWrite.urlMap;
                      var url = urlMap[tile.url] || tile.url;
                      window.localStorage.setItem(
                          "olCache_" + url,
                          canvasContext.canvas.toDataURL(this.imageFormat)
                      );
                  }
              } catch(e) {
                  // local storage full or CORS violation
                  var reason = e.name || e.message;
                  if (reason && this.quotaRegEx.test(reason)) {
                      this.events.triggerEvent("cachefull", {tile: tile});
                  } else {
                      OpenLayers.Console.error(e.toString());
                  }
              }
          }
      }
docs: Method: cache
  Adds a tile to the cache. When the cache is full, the "cachefull" event
  is triggered.
  
  Parameters:
  obj - {Object} Object with a tile property, tile being the
  <OpenLayers.Tile.Image> with the data to add to the cache