"); //-->
本文分享自天翼云开发者社区《分布式系统-秒杀》,作者:胡****冲
开发者模式
URL 动态化
@RequestMapping(value = "/{goodsId}/getUrl")//获取动态 md5 @RequestMapping(value = "/{seckillGoodsId}/{md5}/execution")//执行操作,验证 md5
提前把商品的库存加载到 Redis,
主从
nil
boolean
number
string
table
EVAL 在命令执行完毕并向调用者返回结果之前,只会执行当前命令指定的 Lua 脚本包含的所有逻辑,其它客户端发送的命令将被阻塞 EVAL
if (redis.call('exists', KEYS[1]) == 0) then redis.call('hset', KEYS[1], ARGV[2], 1); redis.call('pexpire', KEYS[1], ARGV[1]); return nil; end; if (redis.call('hexists', KEYS[1], ARGV[2]) == 1) then redis.call('hincrby', KEYS[1], ARGV[2], 1); redis.call('pexpire', KEYS[1], ARGV[1]); return nil; end; return redis.call('pttl', KEYS[1]);
if (redis.call('exists', KEYS[1]) == 0) then redis.call('publish', KEYS[2], ARGV[1]); return 1; end; if (redis.call('hexists', KEYS[1], ARGV[3]) == 0) then return nil; end; local counter = redis.call('hincrby', KEYS[1], ARGV[3], -1); if (counter > 0) then redis.call('pexpire', KEYS[1], ARGV[2]); return 0; else redis.call('del', KEYS[1]); redis.call('publish', KEYS[2], ARGV[1]); return 1; end; return nil;
*博客内容为网友个人发布,仅代表博主个人观点,如有侵权请联系工作人员删除。