gabordemooij/redbean

PartialBeans easier to use and more visible

delafred opened this issue · 4 comments

I'm currently looking how to optimize my code.
Using redbean I didn't notice that by default all fields are updated.

The method R::usePartialBeans(); can help me on that, I also noticed I can apply an array of beans.

I think it could be easier, safer and more visible

  1. to get an option on the method R::store($bean, $option); that can force this parameter
    and/or
  2. to get a special method using this parameter
    ex : R::storePartialBean($bean); / R::storeOnlyModified($bean); / R::storePartial($bean); / R::storeDirty($bean);

I explain

  • using R::usePartialBeans(); before/after a R::store(), I don't know how it will react using multithread throw third librairies and reusing class instance (for optimizations purpose).
  • applying this parameter for the whole project is bit difficult for me ( I don't have an efficient test coverage on this project)
  • somehow it can help developers to discover this functionality that is more efficient and energy saver

thx for this library that helped me a lot

Thank you for your feature request, I will look into it.

Note that PHP has a share-nothing architecture, so on normal webservers it should not affect other threads. This is only a problem if you have a long running PHP application that manages its own threads. Is that the case?

This is only a problem if you have a long running PHP application that manages its own threads. Is that the case?

No I'm not in this case, I was more thinking to use pthreads and reuse of instance of rb.
Note that I'm not an expert in PHP

Thanks to have a look on ths functionnality.

pthreads seems abandoned? https://www.php.net/manual/en/intro.pthreads.php
You can maybe use https://www.php.net/manual/en/book.parallel.php. RedBeanPHP and many aspects of PHP itself are not thread safe though.

pthreads seems abandoned? https://www.php.net/manual/en/intro.pthreads.php You can maybe use https://www.php.net/manual/en/book.parallel.php. RedBeanPHP and many aspects of PHP itself are not thread safe though.

Thanks for the information, I'll have a look.