#!/bin/bash
ip=$1
phone_no=$2
port=$3

mysqld="-h$ip -P$port -uqa -pqatest"

len=`echo $phone_no|awk '{print length($0)}'`
if [ $len -ne 11 ];then
	echo "请输入11位手机号!"
	exit -1
fi

user_id=`mysql -N $mysqld xyqb_user -e "select id from user where phone_no=$phone_no"`
echo "user_id:"$user_id
mysql -N $mysqld xyqb_user -e "delete from contact where user_id=$user_id"

redis_key="contact:contact$user_id"
ret=`redis-cli -h $ip -p 6379 del $redis_key`
if [ $ret -ne 0 ];then
	echo "删除redis缓存成功"
	echo `date`
else
	echo "删除redis缓存失败"
	echo `date`
fi
