public function add_friend($friend, $group) { if (!$this->username) { return array('r' => 'error', 'e' => 'no session found'); } $friend = new Friend($this->username, $friend, $group); $friend_obj_id = $friend->save(); if ($friend_obj_id) { $friend_arr = Friend::get($friend_obj_id); $this->memcache->set('user/' . $this->username . '/friends/add', json_encode($friend_arr)); return array('r' => 'added'); } else { return array('r' => 'error', 'e' => 'invalid user'); } }