Git Product home page Git Product logo

Comments (8)

jdeniau avatar jdeniau commented on June 27, 2024

Totally ! I think it's an easy pick for a PR if you'd like

from rest-client-sdk.

jmfeurprier avatar jmfeurprier commented on June 27, 2024

Hi,

I investigated what was causing the fatal error, and it is more related to proxy generation and caching mixed together than setters:

If I first fetch a partial entity, the entity will be created, using only retrieved values, and will then be stored in cache for later retrieval (using its unique identifier).

If after this, I try to fetch this entity in a "complete" way, its values will be retrieved from cache, and this is when the setters will be called with NULL values because of the way the proxified entities (relations) are handled.

At this point, I thought of another way to make it work: I introduced a special query parameter "_noCache" to explicitely tell the Entity Repository not to cache the retrieved entity. It works, and now performance is great, but this is not what I first had in mind.

This is what the EntityRepository::saveToCache() method looks like now:

    protected function saveToCache($key, $value, array $queryParams = [])
    {
        if (!empty($queryParams['_noCache'])) {
            return;
        }

        // original code here
    }

Call to this method from methods find() and __call() now provide the $queryParams variable.

What's your opinion on this ?

from rest-client-sdk.

jdeniau avatar jdeniau commented on June 27, 2024

Well it may work but as I read it it seems like really custom logic you have to pass in your method from your app and that's not really what we want (the purpose is to be really abstract and powerful).

I'll have to see what we made at mapado because we use partial entities intensively so I think we have made this work, but it may be is custom logic.

An idea would be to change the cache key depending on the request Uri but it may be hard to implement.

@zwit maybe you have remember what we have made?

from rest-client-sdk.

jmfeurprier avatar jmfeurprier commented on June 27, 2024

I'm not satisfied either by the implementation I pasted above. Any idea is welcome.

from rest-client-sdk.

jdeniau avatar jdeniau commented on June 27, 2024

I investigate about this, but I don't really know how it append.

All call to fetchFromCache keys contains the query including the parameters

So if you make two call like /foo/1?_groups[]=bar and /foo/1, you should have two differents HTTP call and two different cache keys and values.

The proxy is then only made when deserializing the JSON in Serializer if you have a relation.

If you use the Symfony bundle, you may have more informations in the debug toolbar.

Can you provide more information like your entities, the sdk configuration part and the call you make (and ideally the output of the rest-client-sdk part in the debug toolbar) to investigate ?

from rest-client-sdk.

jdeniau avatar jdeniau commented on June 27, 2024

@jmfeurprier is the issue still opened ?

from rest-client-sdk.

jmfeurprier avatar jmfeurprier commented on June 27, 2024

Hi,

I switched to other projects which don't use the REST SDK client, so we're not in need any more for fixes (we ended overriding some parts of the tool to suit our customer very specific needs).

Feel free to close the issue.

from rest-client-sdk.

jdeniau avatar jdeniau commented on June 27, 2024

OK thanks.
feel free to re-open the issue if needed

from rest-client-sdk.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.