coldfusion session storage setting from memory to redis not working as expected

Viewed 352

1) I have a very simple script that increments session variable in loop with a sleep 1 second call in it. On status.cfm I dumped the session variable and I can see its incrementing; by refreshing the page time to time.

But when I change session management from memory to redis then what happens is that the session doesn't increment in loop and when the script ends then at that point it store the last value of loop. So if on status.cfm page if I keep refreshing it doesn't reflect changes until the loop script is finished and show last value only, which doesn't server my purpose of monitoring changes to session.

index1.cfm

<cfloop index="i" from="1" to="10">
    <cfscript>sleep(1000)</cfscript>
    <cfset session.counter.foo = i>
</cfloop>

<cfdump var="#session.counter#">

status1.cfm

Checking status...
<cfdump var="#session.counter#">

2) Same scenario as point one, but this time for a thread. And the issue is the tread result doesn't get saved in session and gives the following message instead of thread result object.

coldfusion.runtime.SessionScope$Serialization Problem

index2.cfm

Setting Threads struct {foo="bar", details={}}....
<cfset session.threads_foo = "bar">
<cfset session.thread_details = structNew()>

Creating Thread and dumping....
<cfthread action="run" name="thread01">
    <cfscript>sleep(2000);</cfscript>
    <cfset thread.j=1>
    <cfloop index="i" from="1" to="999999">
        <cfset thread.j=thread.j+1>
    </cfloop>
</cfthread>


<cfset session.thread_details = thread01>

Dumping session variable...
<cfdump var="#session#">
[DONE]<br><br>

status2.cfm

Checking status session threads status...
<cfdump var="#session#">

In PHP there is session_write_close() function that closes the file lock of session so it doesn't wait for the script to end and session file is available to access. Is there anything in coldfusion like that? I'm not sure even if such function exist it would help on redis session which is already a memory storage and not file.

please guide

0 Answers
Related