Thursday, January 21, 2016

Lazy day

Today was cold and lazy day.
I wanted to just lay down and not do anything, but you know.. 😔.
So i managed to import the api data to app engine datastore by pulling and parsing JSON from my current api. Actually i have imported 1 table and 1 more yet to be imported but that is not important. Even if i don't import it, it won't effect a thing but i will try to do that just for the sake of learning.
I tested the new api with my app and its working flawlessly.
I imported the data in local datastore, but the script will import it well in production server when i upload the project to app engine. Tomorrow i will be making a new app engine project and upload the api files to test it again.
I also learnt how to use memcache on app engine. Although it was just few line of code but it makes a huge difference in performance and server costs. What you do here is that you check if the data you looking for is saved in the memcache or not. If its there you serve it right away from memcache. If not you pull it from the datastore and save a copy in  memcache and also serve a copy to user. When next time that data is needed you pull it from the memcache and serve it without doing the roundtrip to the datastore. Memcache, as the name suggest is space in system memory(RAM) that is very fast compared to the disk or datastore so performance improvement is very good. And also app engine gives you restricted queries to datastore in free plan so you save that too by using memcache. If you Move to paid plan you will save cost by using memcache effectively.
I think i need to again read the app engine docs. I read it long back and now i have to look up every time i plan to do anything. This looking into is taking too much time and slowing me down considerably. 
Parsing JSON with python was new experience to me. I used simplejson to parse it. That doesn't mean i have learnt it. I found a sample code and adapted it to work by trial and error but afterward when i looked into the code it looked just like java code i wrote in my android app to parse the same JSON. Just a little syntax difference. Will read little more about simplejson. It will come very handy in long run.
As i have never learnt python in the way i should have, i feel little under confident writing the code but as i write it more i find it far more easier to write and way cleaner than either PHP or java. And writing app engine apps using webapp2 is a bliss compared to writing a vanilla PHP code.
In other news ,for some strange reason i am finding that my system is not loading few websites. It just keep on loading and doesn't show anything. If i try same pages from my phone using the same WiFi connection it loads in a jiffy. Don't know what's the problem. Will try to fix it. May be the problem is in the DNS. If it is then its a quick fix. If not then its going to be headache for me. Just chimed in that the problem may be in the host file i edited recently. Will look into it tomorrow.
What more..
Yes I updated more softwares.
Enough typing on phone on this cold and lazy day.
See ya..

No comments:

Post a Comment