   # Returns promise for a set member
   srandmember: (key) ->
     key = @key key
-    Q @data._private[key][_.random 0, @data._private[key].length - 1]
+    Q @data._private[key]?[_.random 0, @data._private[key]?.length - 1]
 
   # Public: Get all the members of the set
   #

  #
  # Returns promise
  linsert: (key, placement, pivot, value) ->
    key = @key key
    if @data._private[key] isnt undefined
      index = _.find @data._private[key], pivot

      if index
        @data._private[key].splice 0, placement is 'AFTER' ? index + 1 : index, @serialize(value)

    Q @

  # Public: push a new value onto the left-side of the list
  #
  # Returns promise
  lpush: (key, value) ->
    key = @key key
    if @data._private[key] is undefined
      @data._private[key] = []

    @data._private[key].unshift(@serialize value)
    Q @

  # Public: push a new value onto the right-side of the list
  #
  # Returns promise
  rpush: (key, value) ->
    key = @key key
    if @data._private[key] is undefined
      @data._private[key] = []

    @data._private[key].push(@serialize value)
    Q @


  #
  # Returns: promise for the value.
  hget: (table, key) ->
    Q(@deserialize @data._private[@key table]?[key])

  # Public: Delete a field from a hash table
  #
  # Returns promise
  hdel: (table, key) ->
    delete @data._private[@key table]?[key]
    Q @

  # Public: Get the whole hash table as an object.
