生成业务中很多需要 生成随机兑换码 的使用场景。兑换码用于用户兑换、使用范畴。所以兑换码需要有唯一性
不同的业务中,兑换码的生命周期不同。有的业务,从兑换码诞生开始,从始至终保持唯一;而部分业务,兑换码在用户已经使用后,其
实是可以再次生成的。兑换码一般与 订单 绑定,绑定后兑换码生命周期随着订单走。订单已经兑换后,旧的兑换码可以用到新生成的订单中。
这种方式 尤其适用于 较短的兑换码业务。
本服务用于 生成唯一兑换码 场景。
基于 Thrift 服务端
基于 Redis 存储
-
配置与启动
conf 文件夹中 存放 配置文件 例如 config.py config_debug.py 可根据启动方式选择配置文件 运行: cd bin & python server.py debug
-
使用
thrift 调用 create_codes 生成兑换码 具体参数见 thrift 文件 get_code 与 get_codes 均从 生成的库中 随机获取兑换码返回 code_redeem 销毁兑换码