mnapoli / BlackBox

[Experimental] Versatile storage library
http://mnapoli.fr/BlackBox/
14 stars 0 forks source link

ID values #11

Closed assertchris closed 9 years ago

assertchris commented 9 years ago

There's one thing in CacheListStorage that's bothering me: $this->id is kind of like an auto-increment ID, but it lives in the class instance. In the next request, those IDs are back to 0, so getting/setting in the cache will overwrite/conflicts existing entries.

The only + side is the auto-generated ID, but maybe this concept can be brought back to MapStorage?

I like the idea of using unique IDs. The only issue I see is some items having IDs and others not. Perhaps we can store the unique IDs and store the [user-assigned] key along with the value:

$items = [
    "[unique id]" => [
        "key" => "foo",
        "value" => "bar",
    ],
    "[unique id]" => [
        "value" => "baz",
    ],
];

Then we can return numeric indices for unlabelled values and string keys for labelled values (like standard PHP). What do you think?

mnapoli commented 9 years ago

The only issue I see is some items having IDs and others not.

Well if we auto-generate unique IDs when no ID is provided, then every items will have an ID right?

assertchris commented 9 years ago

+1 for auto-generated unique ID.