Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

How to know all options of a function in API of PhalconPHP

I read docs from http://docs.phalconphp.com/en/latest/api/Phalcon%5Cache%5Backend%5File.html function shows like below:

public __construct (Phalcon\Cache\FrontendInterface $frontend, [array $options]) Phalcon\Cache\Backend\File constructor

=> there is an option is "cacheDir" there, so how can I know all of options of "[array $options]" if I can not open phalcon's source codes?

Thank you.



3.6k
Accepted
answer

If I need check something I'm looking in 2.0 branch on github (https://github.com/phalcon/cphalcon/blob/2.0.0/phalcon/cache/) which is written in Zephir (the goal of 2.0 version is compatibility with 1.3 version). Zephir is more similar to PHP and I understand it more or less.

In Phalcon\Cache\Backend\File is only cacheDir option but File cache inherits by Phalcon\Cache\Backend which has also a prefix option.



3.4k
edited Jun '14

Thank you very much.

Another relative question is :

if I has a config like below in services.php:

$di->set('cache', function(){ //Cache Data $frontCache = new Phalcon\Cache\Frontend\Data(array( 'lifetime' => 2592000 )); $cache = new Phalcon\Cache\Backend\File( $frontCache, array( 'cacheDir' => DIR.DS.'..'.DS.'dirwritable'.DS.'cache'.DS.'queries'.DS, 'prefix' => 'query_' ) ); return $cache; });

I use $this->cache-> ... to create cache, and everything works fine.

But how can I change "cacheDir" option from inside controller? it's protected !!!

Phalcon\Cache\Backend\File Object ( [frontend:protected] => Phalcon\Cache\Frontend\Data Object ( [frontendOptions:protected] => Array ( [lifetime] => 2592000 )

    )

[_options:protected] => Array
  (
      [cacheDir] => N:\myp\nc\app\config\..\dirwritable\cache\queries\
      [prefix] => query_
  )

[_prefix:protected] => query_
[_lastKey:protected] => 
[_lastLifetime:protected] => 
[_fresh:protected] => 
[_started:protected] =>

)

Thanks in advance.

I think that Cache are not designed to changing any option after creation of cache instance.



3.4k

Thanks for info