I have created a custom module that allows to subscribe to some news.
Each user ( and there will be thousands of them ) can register to some news category using that form
On form submit, the couple [loti, emails] is stored in a config object, as such:
public function addSubscriberFromLot($lot, $userEmail) {
$config = \Drupal::configFactory()
->getEditable('my_module_news_subscription.settings');
$subscribersforLot = $config->get($lot);
if ($subscribersforLot === null) {
$config->set($lot, [$userEmail])->save();
}
elseif ($subscribersforLot !== null && !(in_array($userEmail, $subscribersforLot))) {
array_push($subscribersforLot, $userEmail);
$config->set($lot, $subscribersforLot)->save();
}
}
the config schema being
my_module_news_subscription.settings:
type: mapping
mapping:
lot1:
type: sequence
label: ‘lot 1’
sequence:
type: string
label: 'Email of subscribers'
lot2:
type: sequence
label: ‘lot 2’
sequence:
type: string
label: 'Email of subscribers'
lot3:
type: sequence
label: ‘lot 3’
sequence:
type: string
label: 'Email of subscribers'
lot4:
type: sequence
label: ‘lot 4’
sequence:
type: string
label: 'Email of subscribers'
lot5:
type: sequence
label: ‘lot 5’
sequence:
type: string
label: 'Email of subscribers'
Is there anything wrong with using that config object for that purpose ?
Can this withstand thousands of entries ?
Is there a more adapted way of store that datas ?