You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have just build a lazy configuration that would read configuration from a database if it is access.
I have done so via a class LazyDatabaseConfig that implements \ArrayAccess and registered it under a key dbc in the config.
Now if dbc.something is accessed Arr automatically calls LazyDatabaseConfig::offsetGet() and provides the config from the database as an accessible array.
This is of course only done once per request..ladidadida.
Now the problem with this solution is, that with the way the configuration is cached right now, we the items are not fetched from the database before the class is exported into the config cache file. var_exported just see that class and does: oh, yeah. Let's LazyDatabaseConfig::__set_state() that baby and be done with it.
I am not sure about a good way to solve this, as I am might as well be the only person that has this problem, but maybe the config could be serialized or passed through something like https://github.com/symfony/var-exporter or whatever to make sure that the data is properly "evaluated" before storing it.
We could also access each and every config key once, so the object is filled properly before it is being serialized.
I guess this being an opt-in feature (since there might be people wanting to fetch config fresh per run) using serialization and their methods might be a better way to implement that.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
Hey,
I have just build a lazy configuration that would read configuration from a database if it is access.
I have done so via a class
LazyDatabaseConfig
that implements\ArrayAccess
and registered it under a keydbc
in the config.Now if
dbc.something
is accessedArr
automatically callsLazyDatabaseConfig::offsetGet()
and provides the config from the database as an accessible array.This is of course only done once per request..ladidadida.
Now the problem with this solution is, that with the way the configuration is
cached
right now, we the items are not fetched from the database before the class is exported into the config cache file.var_exported
just see that class and does: oh, yeah. Let'sLazyDatabaseConfig::__set_state()
that baby and be done with it.I am not sure about a good way to solve this, as I am might as well be the only person that has this problem, but maybe the config could be serialized or passed through something like https://github.com/symfony/var-exporter or whatever to make sure that the data is properly "evaluated" before storing it.
We could also access each and every config key once, so the object is filled properly before it is being serialized.
I guess this being an opt-in feature (since there might be people wanting to fetch config fresh per run) using
serialization
and their methods might be a better way to implement that.What do you guys think?
Beta Was this translation helpful? Give feedback.
All reactions