phalcon / phalcon-devtools

Phalcon Developer Tools
https://docs.phalcon.io/latest/en/devtools
Other
1.33k stars 630 forks source link

Model metadata #607

Closed googlle closed 8 years ago

googlle commented 8 years ago

Hello. Can I generate model metadata with this tool? Because I think if we define the metadata in the model - this is faster than every time they request from the database

Green-Cat commented 8 years ago

There is already a feature in phalcon to cache metadata. You can pick any of the available adapters (filesystem, apc, memcached, memcache, redis and xcache, with some additional ones available on the incubator repo) see https://github.com/phalcon/cphalcon/tree/master/phalcon/mvc/model/metadata

To add metadata caching just add something like this to your services file:

$di->set('modelsMetadata', function () use ($config) {
    return new Phalcon\Mvc\Model\MetaData\Files(
         ['metaDataDir' => $config->application->modelsCacheDir]
    );
});

using the adapter of your choice.

googlle commented 8 years ago

@Green-Cat Thank very much