我正在编写一个使用 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 ?