code: function(map) {
          OpenLayers.Control.prototype.setMap.apply(this, arguments);
          var i, layers = this.layers || map.layers;
          for (i=layers.length-1; i>=0; --i) {
              this.addLayer({layer: layers[i]});
          }
          if (!this.layers) {
              map.events.on({
                  addlayer: this.addLayer,
                  removeLayer: this.removeLayer,
                  scope: this
              });
          }
      }
docs: Constructor: OpenLayers.Control.CacheWrite
  
  Parameters:
  options - {Object} Object with API properties for this control.
   
  Method: setMap
  Set the map property for the control.
  
  Parameters:
  map - {<OpenLayers.Map>}