Flash Ram Questions

CF9, CF 3.0 SVN

I'm having some problems with submitting forms and the flash ram and
I'm wondering if I may be using it in a way that it's not intended to
be used.

1. Is the session flash ram intended for use only by only a relocation
(using setNextEvent()) or can it be used to store short term data
between any two requests in the same session (a setNextEvent(),
cflocation, a form submission, refreshing the page, etc)?

It works perfectly when using setNextEvent() but is giving me problems
preserving data when I submit a form.

2. The "AbstractFlashScope.cfc" has a "getScope" function that makes a
reference to "cbox_flash_temp_storage" in the request scope but that
value is not found anywhere else in the framework so the code below
will always return a new struct.

     if( NOT structKeyExists(request,"cbox_flash_temp_storage") ){
          request["cbox_flash_temp_storage"] = structnew();
     }
     return request["cbox_flash_temp_storage"];

What is "cbox_flash_temp_storage" used for? Are we supposed to set it
up ourselves in the request scope?

Thank you,
Gabriel

I know there is a setting in the config file to define what scope you wish to use for flash ram…defaults to session, if i’m not mistaken, but you can set it to client. As I understand flash ram, it is definitely intended to preserve values between any two events. You can preserve them using the setnextroute/event methods, or there’s a standalone method that lets you manually “stuff” values into flash ram. Values in flash ram are then automatically reinflated into the request context upon arrival at the destination event.

Do I have that right, CBers? :slight_smile:

Doug

  1. “FlashURLPersistScope” determines the scope for the flash ram and allows session, client, cluster, and cache. However, request[“cbox_flash_temp_storage”] is only referenced in that function (although the function itself is called by others) so it’s a mystery as it’s not set anywhere else.

  2. Yeah, it seems like it works perfectly when preserving within the setnextroute/event methods that fire within the framework. And maybe that’s my misunderstanding as I’m looking for it to preserve data between any two requests that come from the same session. A form submission and refreshing the page do not fire “setnextevent” so the flash data disappears.

Thank you,
Gabriel

It is only intended for use as described in scenario #1.

You can use the session directly or the session scope plugin for scenario #2.

HTH

Hi,

Make sure you are not reloading framework on every request.

Should be false
<Setting name="ConfigAutoReload" value="false"/>

Check your environment settings if there any.

Thanks
Sana

Oh, this is a good one. I have like 3 events that check if a value is in the ram flash, and if it is, they ask the ram flash to “keep” it. It worked well with setNextEvent, page refreshes, form submissions… all of it until today.

So Sana pointed out my settings and my “ConfigAutoReload” was already false. But it did lead me to test with my production settings and it worked! Now, my “ConfigAutoReload” was already false so I started testing each of the different settings one at a time. And the culprit was…

… the Coldbox Sidebar!!!

If I have it on, my flash ram doesn’t work like it should. If I turn it off, it works! Crazy.

Still testing but it looks like I’m on my way again. Thank you everyone for helping.

  • Gabriel

RE: “cbox_flash_temp_storage”

It just dawned on me that this value is not referenced anywhere else in the framework because the function itself is setting the value. So within a single request, there may be times where it already exists because the first call to the function created it.

  • Gabriel

Also, note that when you put things into the flash ram via the flash ram object, they are in a staging area and not serialized to the flash containers. This is done to avoid multiple serializations of the flash packets every time you put/delete things into the flash RAM.

The flash RAM get’s saved to the containers whenever you do a relocation using setNextEvent(), or you manually do this by using any of the following:

  1. The saveNow argument on all flash operations: put, putAll,delete, etc.
  2. Using the persistVariables() method on the controller (legacy approach)
  3. Calling the saveFlash() method directly on the flash RAM object.

This is sometimes necessary, as you might have a use case described in this thread, where you store data in the flash RAM object, and then you present a FORM to the user. The user submits but the flash data is not there. Well, it is not there because it was never flashed. Therefore for static use cases, you need to save the flash using the above mentioned states.

For relocations and the like, this is done automatically for you.

Luis F. Majano
President
Ortus Solutions, Corp

ColdBox Platform: http://www.coldbox.org
Linked In: http://www.linkedin.com/pub/3/731/483
Blog: http://www.luismajano.com
IECFUG Manager: http://www.iecfug.com