     clearInterval @saveInterval
     @save => @client.quit()
 
-  # Merge keys loaded from redis against the in memory representation
-  #
-  # Returns nothing
-  #
-  # Caveats: Deeply nested structures don't merge well
-  mergeData: (data) ->
-    for k of (data or { })
-      @data[k] = data[k]
-
 class Robot.Message
   # Represents an incoming message from the chat.
   #

  # Redis connects to a environmental variable REDISTOGO_URL or
  # fallsback to localhost
  constructor: () ->
    @data =
      users: { }

    info = Url.parse process.env.REDISTOGO_URL || 'redis://localhost:6379'
    @client = Redis.createClient(info.port, info.hostname)

class Robot.Brain
  # Represents somewhat persistent storage for the robot.
  #
  # Returns a new Brain with no external storage.  Extend this!
  constructor: () ->
    @data =
      users: { }

  save: (cb) ->
  close: ->

  # Merge keys loaded from a DB against the in memory representation
  #
  # Returns nothing
  #
  # Caveats: Deeply nested structures don't merge well
  mergeData: (data) ->
    for k of (data or { })
      @data[k] = data[k]

class Robot.RedisBrain extends Robot.Brain
  # Represents somewhat persistent storage for the robot.
  #
  # Returns a new Brain that's trying to connect to redis
  #
  # Previously persisted data is loaded on a successful connection
