Subscribe to Grim's Projects        RSS Feed

Mimesis 3.0

Icon Leave Comment
Haven't updated in a while regarding Mimesis, particularly since the 110mb site was down and I had also been busy with some other stuff. The previous version had the disastrous bug of improper file offsets and all that, not to mention still addressing things in a sort of database format.

As I got to coding v3.0 I started moving away more and more from the database way of looking at things and angling more towards a key-value store. The native PHP functions seem to lend themselves better to that end. Not only that I'm not particularly interested in coding sophisticated ways to access/retrieve data. Moreso, I want to store the data and let the operator decide what he wants to do with the data once he's retrieved it, and if he wants to speed it up I leave the challenge up to him as to how to store it intelligently.

So flexibility is the key word here, and with it a simple class with simplistic methods. Following is the list of current Mimesis methods along with a brief description of how they work and the sort of parameters they accept.

Mimesis::Mimesis($cwd, $table)
The constructor, it needs two parameters, the directory where your key-value store will be located and the name of the key-value store.

Mimesis::table($path = NULL)
Returns the name of the key-value store or if you set the parameter the path to the key-value store.

Mimesis::lock($polling = 1, $timeout = NULL)
For creating a lock in order to ensure the atomic nature of filesystem operations, the second parameter indicates the amount of total time to attempt to attain a lock, and the first indicates the interval between attempts.

Releases a previously established lock.

Used to insert values into the store. The parameters are passed doubly as a key and an array of values or a singular value. Example: insertValue('key1', array(1,2,3), 'key2', 4, 'key3', array(5,6)). This operation can create repetition in the value files.

Returns all the values for the requested key, optionally a perl compatible regular expression search can also be used to determine which keys and their respective values to retrieve.

A statistical method that is provided so as to determine the amount of bloat caused by the history present in the store and also repetition of values within it.

Primarily an internal method that is used to facilitate the retrieval of keys and the value files associated with them. Retrieves singular or multiple keys and can also be optionally done as a regular expression retrieval.


Eliminates bloat present in the key files, effectively rewrites the store.


Eliminates bloat present in the value files, effectively rewrites the store.


Deletes the passed keys from the key file and returns an array of value files associated with them so that the operator can then delete those from the system (if they so choose). This operation creates bloat in the key files.


Deletes specific values from a value file. The values are located by their sequential ordering within the value file (the getAllValues method returns its values structured in this way). Example usage: deleteValue('key1', array(0,1,2,3), 'key2', 4). It returns an array with integers each of which represents the total deletions for a particular key. This operation creates bloat in the value files.

Took me a while to decide what to keep and what to remove as some operations seemed superfluous (or more database oriented) and I wanted to keep it as simple as possible. I almost did away with regular expression matching too but figured it could prove useful somewhere down the line. Fixed a couple of bugs as well, one of them caused an infinite loop problem when a deletion took place, that one took a while to track down.

Apart from all that now only 5 external functions are used: desanitize, sanitize, file_place_contents, file_insert_contents and screen. Along with the Mutex class that handles the locking mechanism.

It's almost ready to be uploaded. I've just been lazy about not wanting to convert the tutorials and such because the methods and procedure for making use of Mimesis are all different now. I do so loathe the tedious work.

0 Comments On This Entry