Netscaler数据索引String Map与Pattern Set的区别php
Netscaler中创建索引或子集无疑是解耦先后关联事务的很是好的思路,能够大幅度的减小后期策略的修改,简化管理,下降用户的使用门槛。即使是不常操做netscaler但又偶尔有改动策略需求的管理员,你只要告诉他改一个地方的文件便可完成多条策略的更新工做,而不须要他理解复杂的策略逻辑关系。在netscaler中有data set、pattern set、string map等方式来提供不一样目的的属性子集以供操做。咱们这里先讨论其中两个与字符串相关的类型。
如下是手册中对这两个参数的描述:
String maps are similar in structure to pattern sets (a pattern set defines a mapping of index values to strings; a string map defines a mapping of strings to strings) and the configuration commands for string maps (commands such as add, bind, unbind, remove, and show) are syntactically similar to configuration commands for pattern sets. Also, as with index values in a pattern set, each key in a string map must be unique across the map. The following table illustrates a string map called url_string_map, which contains URLs as keys and values.
String map与Pattern set有不少类似之处,String map的数值是以一对一的状况出现,能够用在字符严格的一对一替换上
而Pattern Set则是以索引的形式来标识字符串,适合用在关键点的选取而非替换上,若是要用做替换只能作多对一或多对多的替换,没法精确到一对一。好的一点是它有索引,能够用策略来选取出其中的索引值来发展更多的应用。app
测试举例:ide
在Responder测Action中应用String map测试
测试效果:
在URL中输入/test
匹配String Map后会被替换成url
而输入/cj
依旧匹配Sting Map但被替换成3d
若是使用一般的办法,只能经过多条策略来实现blog
Action索引
Policy事务
Pattern set则没法实现上述功能,因为Pattern Set在此环境中是多对一个状况,会出现/test和/cj都被替换成/b/index.phprem