Lunch

I make a fruit salad kind of thing almost every single day for lunch. And for some reason, today, I thought I would record the process. This is how I make a fruit salad… How do you do it?

https://videopress.com/v/wp-content/plugins/video/flvplayer.swf?ver=1.18

for the record this is not an exciting or cool video… its just me… cutting up fruit… silently

Nikki In Training

I just want to share with everyone how proud I am of my Nikki. She’s been training to do a half marathon for charity (and to get into shape.) She’s just been stellar about it. She’s walking tons, and lost a bucketload of weight. I’m sure that she would love it if anyone wanted to drop by and give her some words of encouragement on her blog where she’s keeping a log of her Journey. Thats my wife!

lockd, a memcached like locking daemon in php

You might have seen my last post about this code (here) if you are one of my 2.3 loyal readers 😉 . It wasnt nearly so complete or robust then (segfaulting? come on! right?)

The segfaulting was caused by stupidly using $this->function() from inside of $this->function() for recursion, overloading the stack. Note to self: don’t be lazy about recursion 😀

If you’re interested in the project I have it setup over here: http://code.svn.wordpress.org/lockd/ so please feel free to try it out.

 

What is it?  It’s a network based locking mechanism.  You can connect to it over TCPIP and get either exclusive or shared locks for as many arbitrary strings as you like.  Shared locks have the added benefit of being counted.  You can query to see if a string is locked (and how many times for shared locks.) You can also release locks.

 

All of this is useful, but… The nice thing about lockd, though, is that if your client disconnects (say the process which had locked a string quit unexpectedly) lockd will automatically orphan those locks for you.  So you have no need to try and cleanup and guess the lock state of a failed process.   And since this runs as a network daemon you can have as many of them as you like.  You can use them for local (locks on the same box) or distributed (locks on the same resource from many boxes.)  It also comes with built in stats which you could hook up to munin, or nagios, via netcat without too much trouble.

 

The protocol is also extremely simple

  • g (string) — get an exclusive lock on the string
  • sg (string) — get a shared lock on the string
  • r (string) — release an exclusive lock
  • sr (string) — release a shared lock
  • i (string) — inspect an exclusive lock
  • si (string) — inspect a shared lock
  • q — query stats
  • q full — query stats and dump the exclusive and shared lock arrays

 

Thats it.  “(int) (string)” is returned for these commands. where (int) is for programmatic use, and (string) is for human consumption.

 

We use this with the Jobs system (also available as an OSS project) for WordPress.com, Intensedebate, Gravatar, and more, and is currently handling nearly a million operations per day… per server…

 

This is Itch-Scratch-Ware at its finest.