English 中文(简体)
1. 现代化客户
原标题:ColdFusion Serialize Client Variables

期望将会议转换为客户变量,以便我能够迁移到集群环境。

我不禁要问,这样做有没有办法。 我的数字是,我可以撰写一些标准例行公文,其中有一个固定的/固定的,你总是用来确定/获取客户变量。 理想的情况是,这种方法只能存在于每一点/点上。

我正在考虑申请。 客户反对这样做,并做类似的事情

申请:Client.set(名称、变数)

之后

申请。 客户。

序列化将在那里发生。 在走上这条道路之前,任何人都做了类似的事情,根据Stuct vs Array vs Query等的类型,对数据进行分类。

最佳回答

It s going to be tough, because as stated in one of your earlier questions, the CLIENT scope cannot fully emulate the SESSION scope, for the simple fact that it can only include simple vars. You can t store a Structure in CLIENT for example.

但是,这些简单的变式类型之一是一种扼杀。

因此,从理论上讲,如果要设法将复杂的数据结构编成一个星体,它就可以发挥作用。

幸运的是,您有一个机制:<CFWDDX>

<cfset data = StructNew() />
<cfset data.name = "Dale" />
<cfset data.type = "CF Programmer" />

<cfwddx action="cfml2wddx" input="#data#" output="serial" />

<cfset CLIENT.data = serial />

If you glance at your CLIENT.data var (serial) you ll see it looks something like:

<wddxPacket version= 1.0 ><header/><data><struct><var name= TYPE ><string>CF Programmer</string></var><var name= NAME ><string>Dale</string></var></struct></data></wddxPacket>

牢记,这并不是要努力找到所有解决办法。 你无法将氟氯化碳序列化。 还忆及对厨师的大小限制(在有些配置中,可以实际储存生物浓缩变量),因此你有机会从非常庞大的数据结构中丢失数据。

You could wrap this serialization/de-serialization in a CFC that you house in the application scope, as you suggest above. The convenience here with <CFWDDX> is that it is a one-size-fits-all for Structures, Arrays, and all the other types as well.

Maybe not a very robust or long-term solution, but might point you in the right direction.

问题回答

The serializing itself should be the same regardless of the base object. You could either serialize with JSON or with WDDX, but I d go with JSON since that is less verbose. You should note that you ll only be able to store serializable objects in the client scope - if your session scope had references to components, for example, those won t be able to be serialized and stored in the client scope. Aside from that, your basic approach should work fine.

就我的项目之一而言,我采用了同样的做法。 通常,我在每个申请地点都使用客户变量,因此,我把客户变量称作Request,将其加以利用,并储存在申请变量中,以便提供。

hope this help.





相关问题
JQuery AJAX .load - flash chart doesnt load in IE

An IE issue has me completely stumped. I have a coldfusion page that uses JQuery s AJAX .load function to load in a new flash file that is generated by coldFusion s cfchart tag. This works completely ...

Best Coldfusion Library for OpenID [closed]

I am getting ready to start a project that requires using OpenID within Coldfusion 8. I have found a number of different options and was wondering what has worked the best, get s the most support, ...

Find ColdFusion Generated ID

Is there a way to find the elements generated by ColdFusion s <CFLayout> and <CFLayoutArea> tags? These tags: <cflayout type="tab" name="MyAccount"> <cflayoutarea name="...

ColdFusion COM error

I am upgrading from CF4.5 to CF8. Calls to COM dll s that used to work in version 4.5 now throw a "Complex object types cannot be converted to simple values.." error. The COM object has a few arrays ...

What s the best way to write engine-specific CFML code?

Sometimes it is necessary to write different code for Adobe ColdFusion vs Railo vs OpenBD, due to differences in implementation. Do people have a specific method that they use for this? For example, ...

热门标签