Storage

Finally, after much effort, Storage is finally working.

Storage is a backend-agnostic storage engine that was designed specially for Movim. It implements the Active Record pattern. Currently it supports both SQLite and MySQL.

The main advqntages are of course the ability to use many different storage back-ends without modifying Movim, but also to provide quick and easy databases operations without having to do anything special for it. Consider the following example:

class Human extends StorageBase
{
  protected $name;
  protected $age;

  protected function type_init()
  {
    $this->name = StorageType::varchar(32);
    $this->age = StorageType::int();
  }
}

// now we use it.
$me = new Human();
$me->name = 'Etenil';
$me->age = 43;
// saving...
$me->save();

I know this probably could have been achieved by libraries like Doctrine, however it didn’t seem very convincing, and lacked support for nosql databases. Moreover, I tend to suffer from the NMH syndrome…

So for the future releases, we are going to map all XMPP structures to Storage objects and throw away Cache and Session, which will then be useless.

I also report an amazing performance gain when using MySQL instead of SQLite, but you’ll see for yourselves!

Vus : 258
Publié par Movim : 24