Coder Social home page Coder Social logo

Comments (7)

alchimik avatar alchimik commented on September 16, 2024 1

https://github.com/opulencephp/Opulence/blob/1.0/src/Opulence/Views/Compilers/Fortune/Transpiler.php#L191
https://github.com/opulencephp/Opulence/blob/1.0/src/Opulence/Views/Compilers/Fortune/Transpiler.php#L209

Current cache == transpiled cache.

from opulence.

davidbyoung avatar davidbyoung commented on September 16, 2024

The view cache is caching a compiled view, which is dependent on the variables set within the view. So, if the view template is {{ $username }}, this is transpiled to <?php echo htmlentities($username); ?>. If users foo and bar load the page, the compiled views would be foo and bar. It's those compiled views that the cache is loading.

I think what you might be after is a cache for the transpiled view contents, which does not currently exist.

from opulence.

davidbyoung avatar davidbyoung commented on September 16, 2024

To further clarify - I think I need to split the caches out - one for transpiled contents and one for compiled contents. Currently, a single cache is being used, which means that we'll have to re-transpile a view for each combination of variable values. The transpiled cache should not be dependent on variables values - only the compiled cache should.

from opulence.

alchimik avatar alchimik commented on September 16, 2024

If users foo and bar load the page, the compiled views would be foo and bar. It's those compiled views that the cache is loading.

I think it is not.

view: resources/views/username.fortune.php

{{ $username }}

run 1:

        $this->view = $this->viewFactory->createView("username");
        $this->view->setVar('username', 'user1');
        return new Response($this->viewCompiler->compile($this->view));

run 2:

        $this->view = $this->viewFactory->createView("username");
        $this->view->setVar('username', 'user2');
        return new Response($this->viewCompiler->compile($this->view));

caches:

  • tmp/framework/http/views/07ebd14baf059ebf079bd1903c5841fb
  • tmp/framework/http/views/d76eb756c2678439cbc391330a3f9c28

content same

<?php echo $__opulenceFortuneTranspiler->sanitize($username); ?>

from opulence.

davidbyoung avatar davidbyoung commented on September 16, 2024

I think the confusion is with the fact that Transpiler is (incorrectly) using an ICache rather than some sort of transpiler cache, which wouldn't be dependent on variable values. ICache is meant to grab a view object with evaluated contents (eg foo). So, this is an oversight/bug.

from opulence.

davidbyoung avatar davidbyoung commented on September 16, 2024

Btw, on a sidenote - you've been a rockstar contributor! Thanks for all the PRs/help!!

from opulence.

davidbyoung avatar davidbyoung commented on September 16, 2024

The more I think about it, I think we might be able to just scrap the variable component of ICache like you suggested. Let me think about this a little bit and make sure there's not something I'm missing with that approach.

from opulence.

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.