Sitemap
DataDrivenInvestor

empowerment through data, knowledge, and expertise. Join DDI community at https://join.datadriveninvestor.com

Follow publication

Cache Refreshing Techniques

--

Less frequently changing & often accessed data is usually kept in cache to avoid expensive database query operations. This infrequent changing data has to be refreshed at constant intervals so that the cache doesn’t go stale.

Possible strategies of cache maintenance could be of three types :

  • Write Through Cache(writing to cache whenever a DB operation happens)
  • Pull Mechanism (Application Polls at regular intervals to update cache)
  • Push Mechanism (Database notifies application when a record has changed)

All the above approaches are popular , here in this blog we will be discussing the third approach in detail.

Before jumping into it , I am assuming you have basic understanding on IPC, if not , have a look on the article by

on IPC

This example uses MySQL (RDBMS) and Linux Message IPC Queues and then sending it as Notification using Rabbit MQ AMQP to which multiple application listeners consume.

Let’s talk Code

Source code of the TableModifyEvent project is as follows :

Lets see the flow diagram of this TableModifyEvent Application first :

Zoom image will be displayed

You require two classes namely TableEvent and TableEventReader which uses Java Native Access (jna.jar) native code for reading the contents of IPC message queue and forward it to our Rabbit MQ based AMQP Queue.

Secondly you will require to set up MySQL UDF’s(User Defined Functions), as in the example tme.c & db_modify_event.c . Both these c programs need to be compiled as shared files (.so files) and added to mysql plugins folder.

Further More , you will also require a trigger to be created on the Database table on update/insert/delete to send data to IPC message queue.

--

--

DataDrivenInvestor
DataDrivenInvestor

Published in DataDrivenInvestor

empowerment through data, knowledge, and expertise. Join DDI community at https://join.datadriveninvestor.com

Vaibhav Singh
Vaibhav Singh

Written by Vaibhav Singh

I am a #TechnologyEnthusiast #Coder #JavaProgrammer #Blogger (https://linqz.io) #Dreamer. In my free time I love to #Cook, #ShareStories & #VolunteerForPoor.

No responses yet

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy