Using Redis Cache Low Level APIs

Hi,

I have a requirement to fetch data from an external API. The call is pretty costly in terms of performance and the data size is pretty huge. The good thing is the data is relatively static and doesn't change too often. Also, the data is transient in nature. It needs to be used for some intermediate processing and need not be persisted in the BPM'Online database. Ideally, I would like to store this data in the Redis Cache and set an expiry of 3 hours.

Theoretically, it seems possible to access the Redis Cache and get/set the values from/into the cache through the Source Code Schema. I wanted to confirm if there are any recommended ways of doing it? Are there any C# wrappers/classes that are already built in BPM'Online that we can use to get/set/invalidate cache?

Thanks in advance for all the help...

Like 0

Like

4 comments

Dear Amanthena,

There is no possibility to write directly to the Redis cache from the configuration. However, you can write to the Application level cache, which is stored to the Redis. Please see this article to find more info on Application cache:

https://academy.bpmonline.com/documents/technic-sdk/7-13/recommendations-use-different-types-repositories

The access to the Application cache is through UserConnection. ApplicationCache is a dictionary and to read/write you need to do the following:

userConnection.ApplicationCache[«123”] = “qwe”

Hope you find it helpful!

Anastasia

Thank you for all the life-saving help, Anastasia!

Anastasia Botezat,

 

Hi Anastasia,



In your earlier comment, you give an example of how to store a String in the dictionary. Could you share a working code snippet of how we can cache C# objects inside it? 



Ref - https://community.creatio.com/questions/store-object-icachestore-sessio…;

Dear Shrikanth,

 

In order to store an object in Application cache you should serialize the object to string and save the string. Please find more information about serialization in the article by the link below:

 

https://stackoverflow.com/questions/2434534/serialize-an-object-to-string

 

Best regards,

Norton

Show all comments