
NoSQL implementation in PHP
Speed, friends, is one of the important components of your project. As long as the resource is visited by 10-100 users a day, then everything is fine - the user is happy and invites his friends, friends of his friends, and so on. The load is growing ...
For a person who watches photos, reads blogs, listens to music on the Internet, it doesn’t matter what language your site is written in, which DBMS is used and whether you use caching. It is important for him that access to interesting content is as fast as possible.
But over time, a successful project will always require more productivity due to increased project attendance.
Consider a bunch of PHP + MySQL + Memcached .
To show the user an article with comments, you need:
The modern noSQL concept has emerged as an answer to normalized data structures.
Consider the PHP + Memcached bundle in the previous example:
The term “document” appears (for example: an article with comments). To understand more specifically in noSQL technology, I wanted to “come up with a bicycle”as always .
JIM2 prototype
Required: Apache + mod_php + php_xcache
Specify the path where the files will be stored:
Usage Example:
Recording
reading
For a person who watches photos, reads blogs, listens to music on the Internet, it doesn’t matter what language your site is written in, which DBMS is used and whether you use caching. It is important for him that access to interesting content is as fast as possible.
But over time, a successful project will always require more productivity due to increased project attendance.
Consider a bunch of PHP + MySQL + Memcached .
To show the user an article with comments, you need:
- See if there is an article (with comments) in the cache
- If not, then make “dear” JOIN text + comments
- Put everything in the cache
- Share content with user
The modern noSQL concept has emerged as an answer to normalized data structures.
Consider the PHP + Memcached bundle in the previous example:
- See if there is an article (with comments) in the cache
- If not, then put it in the cache
- Share content with user
The term “document” appears (for example: an article with comments). To understand more specifically in noSQL technology, I wanted to “come up with a bicycle”
JIM2 prototype
Required: Apache + mod_php + php_xcache
Specify the path where the files will be stored:
define('STORAGE_PATH', 'F:\\tmp\\jim2');
Usage Example:
Recording
$collection = new Collection();
$vasya = array
(
'name' => 'Vasya',
'sex' => 'male'
);
$masha = array
(
'name' => 'Masha',
'sex' => 'female'
);
$jim = array
(
'name' => 'Jim',
'sex' => 'male',
'type' => 'dog'
);
$collection->put($vasya);
$collection->put($masha);
$collection->put($jim);
$collection->createIndex( array ('name+sex', 'sex') );
reading
$collection = new Collection();
$keys = xcache_get('./index/sex/male');
foreach ($keys as $key)
{
print_r( $collection->get($key) );
}
Features:- Documents are stored as key / value
- Using document properties, you can build indexes (additional keys are created)
- Each document has a _rev field indicating the version of the document. This will prevent collisions when locking the file for writing, as document versions are checked
- Also, the collection itself stores the version. Made so that you can verify the relevance of caches built on the basis of a collection of documents
- Fetching a collection using the API
- Pagination
- ... any of your suggestions