I've seen many questions on this topic, but none of them covers my case.
I am building an ACL module based on 5 classes:
I am thinking to use the SplQueue to store the privileges levels(mainly for the inherited privileges) So I am thinking to use a single object to store everything and do not think that the normal multi-dimensional array will be the best choice. The flow will be like this paste, it is TL;DR.. Sorry about that.
So my question is will the SplQueue be an overkill in my case?
Should I use and alternative Spl Data Structure, and if so which one?
EDIT Well I couldn't think of a good example of the usage, so lets keep to the UNIX based GBAC.
If you want to store your data in the object form then the use the SplObjectStorage
. The SplQueue will overkill for small array.
SplQueue works on FIFO.
So you cann't access directly to last or near to the last and will take time.
Instead of SplQueue
I will suggest you use the Array as you can access any element directly by array index.
You can also check the answer of this question: Associative Array versus SplObjectStorage
Also you can check the the performance of SPLobjectStorage and array, here is the code.
For more read here.
SplObjectStorage definitely scaled linearly. Array performance was less predictable (larger standard deviation) with smaller data sets. And SplObjectStorage is indeed a better solution for storing lots of objects in a set.
So if your data is small then you should use the array otherwise use the SplObjectStorage
for large amount of data.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With