code: func (p *Plugin) SetMemory(in *Msg, k string, v interface{}) {
  	b, err := json.Marshal(v)
  	if err != nil {
  		p.Log.Infof("could not marshal memory interface to json at %s. %s",
  			k, err.Error())
  		return
  	}
  	p.Log.Debug("setting memory for", k, "to", string(b))
  	if in.User.ID > 0 {
  		q := `INSERT INTO states (key, value, pluginname, userid)
  		      VALUES ($1, $2, $3, $4)
  		      ON CONFLICT (userid, pluginname, key)
  		      DO UPDATE SET value=$2`
  		_, err = p.DB.Exec(q, k, b, p.Config.Name, in.User.ID)
  	} else {
  		q := `INSERT INTO states
  		      (key, value, pluginname, flexid, flexidtype)
  		      VALUES ($1, $2, $3, $4, $5)
  		      ON CONFLICT (flexid, flexidtype, pluginname, key)
  		      DO UPDATE SET value=$2`
  		_, err = p.DB.Exec(q, k, b, p.Config.Name, in.User.FlexID,
  			in.User.FlexIDType)
  	}
  	if err != nil {
  		p.Log.Infof("could not set memory at %s to %s. %s", k, v,
  			err.Error())
  		return
  	}
  }
docs: // SetMemory saves to some key to some value in Abot's memory, which can be
  // accessed by any state or plugin. Memories are stored in a key-value format,
  // and any marshalable/unmarshalable datatype can be stored and retrieved.
  // Note that Ava's memory is global, peristed across plugins. This enables
  // plugins that subscribe to an agreed-upon memory API to communicate between
  // themselves. Thus, if it's absolutely necessary that no some other plugins
  // modify or access a memory, use a long key unlikely to collide with any other
  // plugin's.