(Reposted from
http://krow.livejournal.com/565174.html)
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)).