私は、iniファイルを使用してすべてのステータスコード(エラー、成功コードなど)を格納するアプリケーションを作成しています。非常に単純なバージョンは次のとおりです。
[success]
000=Status code not found.
[error]
000=Error code not found.
001=Username/Password not found.
そして、それを操作するCFコンポーネントは、次のコードを使用します。
component hint="Set of tools to interact with status codes."{
public function init(string codefile) any{
this.codefile = Arguments.codefile;
}
public function getCodeString(string type, string code) string{
var code = getProfileString(Variables.codefile, Arguments.type, Arguments.code);
return code;
}
}
getProfileStringを呼び出すと、Railoがファイルを開き、キーを検索して値を返すと思います。したがって、アプリケーションが大きくなり、コードが増えるにつれて、このプロセスの速度が低下すると予想されます。では、initメソッドでファイルを開き、すべてを変数スコープに読み込んで、そこからgetProfileStringを呼び出す方法はありますか?