eThreads: the need for speed

Friday, November 26, 2004, at 07:02PM

By Eric Richardson

I just put a new eThreads snapshot in place, so hopefully things will feel a little faster here. I'm valuing speed over a small memory footprint, so I added a cache in memory. I also rewrote the way internal links work (links within the blog... all URLs stay the same) to do some stuff I couldn't do without good speed.

Most of what I did wouldn't make any sense to anyone but me, but here's the kind of cool stuff the new link structure does: the template being linked to determines what the link looks like. A simple example: From the main page I link post titles to the permanent URL for the post. In the template code on the main page there's this little snippet:

{link "/blog"}{qopt "id"}{$p.id/}{/qopt}{/link}

That tells the link code that we're linking to the /blog template. It then loads up that template and makes sure "id" is an option /blog's looking for. At that point it knows it can link to /blog?id=$id. But it also looks at the /blog template's keys, and sees that it has id defined as a key. That means that it can link a cleaner URL as /blog/$id. That's the one it uses.

Now I just have to keep an eye on memory usage and figure out how best to expire things out of the cache. Fun fun fun.