0

i have a news website that update once-twice in a day, and i want to develop something that will let my users know when there is new content in my website, it will popup them a notification, only one notification per each content its sound easy the problem that i face is how i make it efficient in crossrider without every page reload make a call to the database?

how i doing it right now(not efficient) i have in my server php file that post the id's of the last news, the crossrider read that file and for each id it call the crossrider db and check if that id exists if yes than the user has already recive a notification about that content and should not be notificated, and if its not exists than notify the user. so as you can see every reload of a page the extension will make a call to my server and to the db server. any better way to build this? thank you

Amir Bar
  • 3,007
  • 2
  • 29
  • 47

1 Answers1

1

If I understand your query correctly, you can gain an immediate efficiency by calling the Crossrider db using appAPI.db.getList to obtain an array of all the database items (instead of calling the database for each id), and then process the ids against them.

I'm happy to look into other ways of improving the efficiency of your algorithm if you provide the extension id.

Shlomo
  • 3,763
  • 11
  • 16
  • hi Shlomo thanks, i think i didnt explain myself correctly, its not efficient to check against my site db and than against crossfire db each time someone refresh a website, lets say 100 people using the exstension and they surfing the net in the same time for 1 hour so there gonna be for each person a lets say 1000X2X100 calls to the database, what i am looking for is somthing lest say check for new content once in an hour for example, i looking for something like cookies,i can put lastTimeCheck in crossfire db and check against it every time but i am afraid to flood their db – Amir Bar Nov 25 '12 at 14:44
  • Let me clarify, the Crossrider db IS local and similar in that sense to cookies (see description in [appAPI.db](http://docs.crossrider.com/#!/api/appAPI.db)). As for lastTimeCheck, you can use the db expiration feature to expire data items after a period of time that you specify. The Crossrider db will automatically remove the data item when it expires, such that if you make a call to get the data item ([appAPI.db.get](http://docs.crossrider.com/#!/api/appAPI.db-method-get)) and it returns null, you know it's time to get a fresh copy of the data. Hope that helps. – Shlomo Nov 25 '12 at 18:31