Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[NFR]: Active Record - First Level Cache #66

Open
rudiservo opened this issue Nov 12, 2020 · 0 comments
Open

[NFR]: Active Record - First Level Cache #66

rudiservo opened this issue Nov 12, 2020 · 0 comments
Labels
new feature request Planned Feature or New Feature Request

Comments

@rudiservo
Copy link
Contributor

rudiservo commented Nov 12, 2020

TL:DR - This one in on me, I did promisse to add to phalcon and I will, but it is not a simple problem I do have a working proptotype in PHP on a project for the past 10 months and tinkering, now we all know what happen since then.

First Level Cache is caching the models that you request from the database instead of fetching a new one everytime.
For example:
$owner->id = 1;
$owner->name = 'Test';
$owner->robots = [$robot];
$owner->save();

So far so good but
$robot->owner->name = 'Phalcon';
echo $owner->name; # output will be Test instead of Phalcon

it will fetch the model again to the database keeping a single source of truth

Also add to hasMany some ArrayObject fuctionality and others

I got working somewhat the append, remove and delete
For example

$owner->robots->append($robot);
$owner->robots->remove($robot)
$owner->robots->delete($robot)

I would like to add also a iterator, it would help to remove or delete model relations while iterating with a for or a while.
The iterator is important because if we remove one object from a current array the total shrinks to -1, meaning that you will skip one model in the relation.

Hopefuly "The WeakReference class" can be used for this, it provides better memory management since hopefully it wont prevent GC from doing it's thing.
https://www.php.net/manual/en/class.weakreference.php

@niden has soon has we have coverage of MVC I will get to work.

@rudiservo rudiservo added the new feature request Planned Feature or New Feature Request label Nov 12, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new feature request Planned Feature or New Feature Request
Projects
None yet
Development

No branches or pull requests

1 participant