更新时间:2022-05-27 01:09:25
中等水平的设计可能就像
*有一个表COUNTERS(ID,currentValue,maskingRules)
*有值(1,1,'yymmdd9999')
*有一个SQL函数关注
*阅读掩蔽规则
*解析它并相应填写
*更新CurrentValue
*返回业务层的累计价值
这将有助于以下方式
*您有一个可以轻松测试的独立功能
*您可以定义不同的屏蔽规则
*您可以立即更改规则(在制作时)
这种方法确实有副作用,重要的一个是COUNTERS表,如果定义了太多的计数器,就会因为锁而自行成为负载的瓶颈
A moderate level design could be like
* Have a table COUNTERS(ID, currentValue, maskingRules)
* With values (1, 1, 'yymmdd9999')
* Have a SQL Function which does following
* Read masking rule
* Parse it and fill it accordingly
* Update CurrentValue
* Return the accumulated value to the business layer
This will help in following ways
* You have an independent function that can be easily tested
* You can define different masking rules
* You can change the rules instantly (on production)
This approach do have side effects, significant one is the COUNTERS table could it self be a bottleneck on load because of locks if too many counters have been defined