Bones' Blog of Stuff About Things

30 Jul

The Near Done Thing

First of all, some good progress has been made today, so “Yay me”. I’ve sorted the per mod_python instance persistence issue and also implemented the first layer of image caching. The result on the page is as yet only noticeable if you keep refreshing for the most part as the update is once a minute, which means the cache gets wiped often, however, the page creation time when you hit the cache is down to 0.2s or so, and I just have to split off the various updating sections from the geography layer that doesn’t change very often and that should be about the time it takes for all requests as long as the underlying map remains unchanged.

At some point I’m going to try doing it all from the DB and storing each cell and selecting out only those for the map in question, but that will involve some measure of understanding of how to achieve spacial indexing/selection on a DB that is a little beyond me right now. I mean, it’s obvious that you could do it, but how you would do it so that it’s fast on a table with a million rows… perhaps I should drop Jim Gray an email.

So, the near done thing:

Part of the job of a cache is to not provide stale data, and my image cache is no different. In order to avoid the problem, I implemented a simple mechanism that deletes all files in a directory and passed the cache dir to it. This worked fine in my test setup running under the editor, I simply setup the cache dir in a directory relative to the current working directory and it did its thing. In fact, it worked so well that I was just going to copy the library modules over, and cut and paste the relative directory code into the mod_python handler in order to set up the cache directory. At the last minute, I had a change of heart based on the number of misunderstandings that occur between me and the Linux box and so I did a test, and ran the cache clearing code to print out the filenames it was going to delete.

Reading the list made me feel a little ill. Which is not a surprise seeing as mod_python considers ‘/’ to be its working directory and I had neglected to add the code to create the offset. :O

Comments are closed.

© 2010 Bones' Blog of Stuff About Things | Entries (RSS) and Comments (RSS)

GPS Reviews and news from GPS Gazettewordpress logo