dpGetCache dpSetCache improvement

Find and share HowTos to various installations / configurations!
Search

Post Reply
3 posts • Page 1 of 1
pvillegasGTD
Posts: 6
Joined: Tue Jan 28, 2020 1:01 pm

dpGetCache dpSetCache improvement

Post by pvillegasGTD »

Hello,

I would like to be able to write to the cache of a dp without writting to the DB.

I.e: I have some static values on the DB and I want to query them a lot of times. It'd be nice to be able to fill the cache with current state of the dps without rewritting the values on the DB.

I think now it's not possible as dpSetCache always does a dpSet.

¿Am I missing something?

Thanks

Regards,
Pau

pvillegasGTD
Posts: 6
Joined: Tue Jan 28, 2020 1:01 pm

Re: dpGetCache dpSetCache improvement

Post by pvillegasGTD »

Hello again,

I found the issue.

dpGetCache is also saving the value of the dp (dpGet) into the cache if the dp is not already in it. This means that dpSetCache is not required.

In order to do what I wanted is required to first do a dpRemoveCache(dp) and then a dpGetCache(dp). This will init the cache with current value of the dp.

Afterwards, dpGetCache will return the values without doing a dpGet.

Regards,
Pau

User avatar
leoknipp
Posts: 2926
Joined: Tue Aug 24, 2010 7:28 pm

Re: dpGetCache dpSetCache improvement

Post by leoknipp »

If you want to use dpGetCache() and dpSetCache() you have to be very careful. The cache only works for a single manager. If another manager is using the same data you will possibly get different results.
When you just want to store information in memory you can also use global variables. This might be easier then using the "cache" functions.

Best Regards
Leopold Knipp
Senior Support Specialist

Post Reply
3 posts • Page 1 of 1