Log in

No account? Create an account

More fun with the memcached engine :)

« previous entry | next entry »
Nov. 16th, 2007 | 12:51 am

So a bit more of the engine now works :)

mysql> CREATE TABLE `m` (
     ->   `a` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
     ->   `b` varchar(100) DEFAULT NULL,
     ->   `c` int(11) DEFAULT NULL,
     ->   UNIQUE KEY `a` (`a`)
     -> ) ENGINE=MEMCACHE DEFAULT CHARSET=latin1 CONNECTION='localhost,piggy,bitters' ;
Query OK, 0 rows affected (0.01 sec)

mysql> insert into m VALUES (0, "this is mine", 23);
Query OK, 1 row affected (0.01 sec)

mysql> insert into m VALUES (0, "this yours mine", 42);
Query OK, 1 row affected (0.00 sec)

mysql> insert into m VALUES (0, "this ours mine", 67);
Query OK, 1 row affected (0.00 sec)
mysql> select * from m;
| a | b               | c    |
| 1 | this is mine    |   23 |
| 2 | this yours mine |   42 |
| 3 | this ours mine  |   67 |
3 rows in set (0.01 sec)

mysql> select * from m ORDER BY a DESC;
| a | b               | c    |
| 3 | this ours mine  |   67 |
| 2 | this yours mine |   42 |
| 1 | this is mine    |   23 |
3 rows in set (0.00 sec)

The three big changes:
  • The engine can now scan rows. The solution is doing single get fetches, but I'll switch this over to being multi-get (and probably extend libmemcached in the process since the API doesn't cover a case like this). This requires at the moment that you use an auto increment as the primary key.
  • I've add support for Auto Increment, good thing since you need it for scanning!
  • Multiple indexes are supported now (though not multi-part keys).

    Some progress :)

    Most likely I'll package this up sometime in the next couple of days. It is still not useable in production, but it is fun to play with :)

    (UPDATE Scratch the limitation on the primary key having to be an autoincrement, I thought that was lame. It took a bit of refactoring, but the key can now be a varchar (though not a char... space preservation will have to be solved)).
  • Link | Leave a comment |

    Comments {2}

    Patrick Galbraith


    from: capttofu
    date: Nov. 16th, 2007 06:49 pm (UTC)

    This is great! Can applications, say perl apps, read from that memcached table in it's raw form? Say for instance, I have a master that has an app that inserts a feed into a myisam table. On the slave, that table is a memcached table. Could the perl app read directly from the memcached table - side-step MySQL, looking up with some hash key?

    Reply | Thread

    Brian "Krow" Aker

    Re: excellent!

    from: krow
    date: Nov. 16th, 2007 08:05 pm (UTC)

    Yes they can. Right now I am serializing into XML (well... binary by default, XML if you want). I have plans on doing something a bit more efficient in the near term.

    Reply | Parent | Thread