From: Thomas Hurst Date: 2003-08-28T19:29:28+09:00 Subject: Re: Another Ruby-powered site * Michael Campbell (michael_s_campbell@yahoo.com) wrote: > > But qurl.net is Ruby *and* FreeBSD driven! Those are two good > > reasons to support it. Just think "religion". ;) > > I see the smiley so the intent here isn't lost on me.Playing devil's > advocate however, I'm just too old and tired for religion anymore.I > used to fight the good fight and all that, and these days, I'm looking > for whatever easiest/best solves the problem at hand. No religion here; Ruby and FreeBSD are simply what get the job done best in my experience :) > That said, qurl.com is neat, and since I can tune the redirect > time-delay to my liking, I might use it. I'm only concerned about its > longevity.I got the impression from the author that this was thrown > up on a whim; is it meant to be permanent? Pretty much.It was thrown together on a whim, but it's not exactly expensive to keep running.I might change the URL allocation stuff if my choice of characters proves to be a little too optimistic, but I think that's unlikely (I was quite careful to pick URL safe characters). There's space for ~2000 URL's in http://qurl.net/XX, btw; over 110,000 in /XXX.I wonder how effecient that is compared with tinyurl and shorterlink. Keeping on-topic; I did look at some of the caching modules people have written, but they struck me as being rather ineffecient, involving walking arrays equal to the size of the cache on each hit etc. Rather than use one of these, I made this half-assed attempt: class WeakRefHash < Hash def [](key) v = super(key) default unless (v and v.weakref_alive?) end def []=(key, value) super(key, WeakRef.new(value)) end end Which is obviously less than optimal. Does anyone have any nicer solutions? :) -- Thomas 'Freaky' Hurst - freaky@aagh.net - http://www.aagh.net/