Download the PHP package egorov/mapper without Composer
On this page you can find all versions of the php package egorov/mapper. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download egorov/mapper
More information about egorov/mapper
Files in egorov/mapper
Informations about the package mapper
Tarantool Mapper
- Installation
- Instantiate mapper
- Logging
- Existing types
- Describe entities
- Use migrations
- Use fluent api
- Working with the data
- Indexes
- Array properties
- Sequence plugin
- User-defined classes plugin
- Annotation plugin
- Internals
- Performance
Installation
The recommended way to install the library is through Composer:
Instantiate mapper
Usually, you manage dependencies in your service provider. To get started you should instantiate connection, packer, client and mapper itself. In this example we use PurePacker and StreamConnection. It means you don't need any pecl extensions. To see other implementations please check client documentation
Logging
By default, client does not logs tarantool requests, you can use mapper\client that supports logging.
Existing types
You can start with your current configuration. Please, note - all instances are mapped to key-value objects.
Describe entities
To get started you should describe your types and fields using meta object.
Use migrations
Use fluent api
Working with the data
Now you can store and retreive data from tarantool storage using mapper instance.
Indexes
Array properties
You can store arrays as property without any serialization to string.
Sequence plugin
If you want you can use sequence plugin that generates next value based on sequence space. Or you can implement id generator using any other source, for example with raft protocol.
User-defined classes plugin
If you want you can specify classes to use for repository and entity instances. Entity and repository class implementation are ommited, but you should just extend base classes.
Annotation plugin
You can describe your entities using dobclock. Mapper will create space, format and indexes for you.
If you want to index fields, extend repository and define indexes property
Register plugin and all your classes:
Internals
Mapper uses IdentityMap and query caching
Performance
Mapper overhead depends on amount of rows and operation type. Table contains overhead in milliseconds per entity. In some cases, overhead can't be calculated due float precision.
Operation | 100 | 1000 | 10 000 | 100 000 |
---|---|---|---|---|
create entity one by one | 0.017 | 0.022 | 0.023 | 0.024 |
select entity one by one | - | 0.015 | 0.016 | 0.018 |
one select for all entites | - | - | 0.002 | 0.006 |
Perfomance test was made on (intel i5-6400), bash for windows 10 using php 7.0.18. For example, when single select will produce 10 000 entites, you will get 20ms overhead.