Welcome to the SRP Forum! Please refer to the SRP Forum FAQ post if you have any questions regarding how the forum works.

Database_Services("ReadDataRow"

I have this in my api which reads a control file record which, as I would like it kept in memory after first read, set the notexpired to 0.
I was wondering what forces this to do a fresh read. Does it stay in memory for weeks?
I was just wondering what would happen if a value in the record was changed, how would a fresh read be forced.
Is there some sort of session signature that is used also, so if the user closed the web app, that would force a new read next time run.

NotExpired=0
rv = Database_Services("ReadDataRow", TableName, KeyID, NotExpired)

Comments

  • I'm sure you'll get a more definitive answer from the source but in case they've switched off for the evening, (yes, I know that never happens), my initial thoughts are this.
    1. Setting notExpired to 0 is the same as setting expired to true. In other words, you're telling the system to always read; the opposite of what you seem to be asking for.
    2. Unless you've changed it, (and you may have), each request cleans up after itself, so if you do set notExpired to true it still only lasts for the duration of the current request.
    3. The next parameter in this service is the duration which defaults to zero. I'd hazard a guess that has the same effect as saying it has expired and leads to a fresh read as well.
    In summary, and I'm sure @Don will correct me if need be, if you want a record to just stay in memory, you need to set notExpired to true$ and set an expirationDuration indicating how long you want it to stay in memory but no matter what you set, it's likely cleared out at the end of each request.
    It's not a stay all day, all week or indefinitely scenario.
  • Thanks Mark, I must have misinterpreted what I read.
  • Sorry, Mark, Looking at memoryservices I am going to have to disagree with you on NotExpired=0 (gets from memory each time)
  • No apologies necessary. You've probably done a more thorough dig than I have
  • edited August 2022
    @BarryStevens, looks like you're right on with the notExpired value.
    I read your post and took notExpired to represent a status but instead it seems to be an indication of intent.

    In other words, I thought "notExpired = true" meant this record has notExpired.
    What it really appears to mean is "do the check to see if this record has expired" so setting it to false skips the check, assumes it hasn't expired and automatically reads from memory.

    I should have known you'd investigated thoroughly before asking the question and not just spat out my initial thoughts. :D

    I think the, valid for this request only, response still stands, though good chance you've been down that rabbithole before posting too.
  • I will wait for Don's response before I go any further with this.
  • I have this in my api which reads a control file record which, as I would like it kept in memory after first read, set the notexpired to 0.
    I was wondering what forces this to do a fresh read. Does it stay in memory for weeks?


    There are three conditions when a fresh read is occurs:
    • This is the first time the row is being read in the session.
    • NotExpired is explicitly set to 0 (False$).
    • NotExpired is set to anything other than 0 AND the last time the row was read was longer than the value set in ExpirationDuration.
    Your code as written will force a fresh read. If you want to cache the row then set NotExpired to 1 (True$) and ExpirationDuration to a very long time (e.g., 86400, which is 1 day).

    I was just wondering what would happen if a value in the record was changed, how would a fresh read be forced.
    Is there some sort of session signature that is used also, so if the user closed the web app, that would force a new read next time run.


    Every session starts with a new cache.
Sign In or Register to comment.