ユ,スケ,ス:ユ,ザ,権限のキャッシュ
このユースケースでは,外部Webサービスからユーザー権限(“黄金”,“银”など)を取得する必要があります。
このユ,スケ,スを実現するには,次の操作を実行します
HTTPコルアウトを作成して,外部Webサビスからユザ権限を取得します。
add policy httpcallout [-IPAddress ] [-port ] [-vServer ] [-returnType ] [-httpMethod (GET | POST)] [-hostExpr ] [-urlStemExpr ] [-headers …[-parameters …][-bodyExpr ][-fullReqExpr ][-scheme (http | https)] [-resultExpr ][-cacheForSecs ] [-comment ] add policy httpcallout get_user_privilege -ipaddress 10.217.193.84 -port 80 -returnType text -httpMethod GET -hostExpr '"/get_user_privilege"' -resultExpr 'http.res.body(5)'
権限を変数に格納します。
add ns变量 -type [-scope (global | transaction)][-ifFull (undef | lru)][-ifValueTooBig (undef | truncate)][-ifNoValue (undef | init)][-init ] [-expires ] [-comment ] add ns变量user_privilege_map -type map(text(15),text(10),10000) -expires 1200 add ns assign set_user_privilege -variable $user_privilege_map[client.ip. ip。-set sys.http_callout(get_user_privilege)
クライアントのIPアドレスのキャッシュされたエントリがすでに存在するかどうかをチェックするポリシーを作成します。存在しない場合は,httpコルアウトを呼び出して,クラアントのマップエントリを設定します。
add cmp policy -rule -resAction add cmp policy set_user_privilege_pol -rule $user_privilege_map.valueExists(client.ip.src)set_user_privilege>
クラアントのキャッシュされた特権エントリが“黄金”である場合に圧縮するポリシを作成します。
add cmp policy -rule -resAction add cmp policy compress_if_gold_privilege_pol -rule '$user_privilege_map[client.ip.src].eq("GOLD")' -resAction compress
圧縮ポリシをグロバルにバンドします。
bind cmp global [-priority ] [-state (ENABLED | DISABLED)] [-gotoPriorityExpression ] [-type ] [-invoke ( )] bind cmp global set_user_privilege_pol -priority 10 NEXT bind cmp global compress_if_gold_privilege_pol -priority 20 END
ユ,スケ,ス:ユ,ザ,権限のキャッシュ
この記事の概要
コピ,完了
コピ,失敗