NetTalk Central

Author Topic: Global MEMORY file  (Read 208 times)

JohanR

  • Sr. Member
  • ****
  • Posts: 416
    • View Profile
    • Email
Global MEMORY file
« on: August 03, 2026, 11:11:57 PM »
Hi,

I need a global MEMORY file with about 200 records that should be available to all sessions.
Data in the MEMORY file would be loaded/refreshed once a day

Sessions would read this data and use it in Netwebsource procedures to build HTML using local queues.

What is best practise and best place to load the data for safest and optimal performance.



thanks

Johan

Jane

  • Sr. Member
  • ****
  • Posts: 430
  • Expert on nothing with opinions on everything.
    • View Profile
    • Email
Re: Global MEMORY file
« Reply #1 on: August 04, 2026, 11:37:11 AM »
For something small like that, you might also consider Capesoft MaxQueue.

As for loading the queue (or file), is the data pre-staged (in which case the load would be almost instantaneous) or does it have to be gathered?

I have some webservers that need the underlying data refreshed periodically.  Perhaps I overcomplicate things, but my flow is:

1. When the app starts, START a window that has a timer.  Capture the thread returned by the START command into a global variable (I use GLO:DataServiceThread).
2. I declare an equate   
Code: [Select]
eqMyClose           equate(event:user + 4) 3. In the window that has a timer, in ThisWindow.TakeWindowEvent before the parent
Code: [Select]
        of eqMyClose
            ! any other cleanup code here
            post(event:closewindow) 
4. In the webserver procedure, at the beginning of thisWindow.Kill
Code: [Select]
    if GLO:DataServiceThread <> 0
      post(eqMyClose,,GLO:DataServiceThread)
    end ! if
5. Timer in window triggers refresh of data.
6. You might want to wrap the actual reloading of your data inside a critical section to restrict access while the refresh is taking place.  Don't know whether that is needed with MaxQueue.

JohanR

  • Sr. Member
  • ****
  • Posts: 416
    • View Profile
    • Email
Re: Global MEMORY file
« Reply #2 on: August 05, 2026, 04:48:24 AM »
Hi Jane

Thanks for the detailed reply,
I like the STARTED procedure with the timer running.
This way if I want to add other similar procedures they will be kept separate and organization will be clean.

Multi-host?
Would this be checked and started from the webserver or webhandler, just thinking about multihost situation.

thanks

Johan


Jane

  • Sr. Member
  • ****
  • Posts: 430
  • Expert on nothing with opinions on everything.
    • View Profile
    • Email
Re: Global MEMORY file
« Reply #3 on: August 05, 2026, 04:36:17 PM »
Johan,

I've never used the multi-host for a real app; just played with the example.

I would not start from the webhandler.

Many of my web servers actually have a source procedure as the first procedure in the app tree. 
This is example code from one that looks at the commandline, does some initialization, starts a timer window, and then runs the web server.

Code: [Select]
    GlobalInit()
    IF COMMAND('/setup')
      SetupWindow()
      RETURN
    END ! IF         

    if GLO:LogMaxRecords = 0
      GLO:LogMaxRecords = 500
    end ! if     
       
    GLO:RunningAsService = gSelfService.AmService
    GLO:SuppressUI = GLO:RunningAsService
       
    GLO:DataServiceThread = start(timerwindow,25000)

    if GLO:RunningAsService
      AddErrorLog('ADIS started as service.')
    ELSE
      AddErrorLog('ADIS started manually.')
    end ! i
       
    GLO:ServerStartDate = today()
    GLO:ServerStartTime = clock()

    WebServer()