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

Caching search results #12

Open
rroblik opened this issue Aug 21, 2015 · 1 comment
Open

Caching search results #12

rroblik opened this issue Aug 21, 2015 · 1 comment

Comments

@rroblik
Copy link

rroblik commented Aug 21, 2015

Hi,

Thanks for all the work done on restful module and on this restful_search_api module :)

I see that restful module provide storage capabilities which are not used in restful_search_api and I think that is a huge performance issue ...
The setRenderedCache() function (from RestfulBase.php) is never called.

I think the best place to add cache logic is in public function view($id) method isn't it ?

Thanks

@rroblik
Copy link
Author

rroblik commented Aug 21, 2015

Ok I made a "workaround"

class RestfulSearchAPIMySearchClass extends \RestfulDataProviderSearchAPI implements \RestfulInterface {

// ...

public function view($id) {
    // To generate an unique cache id
    $cache_context = array(
      'search_keywords' => $id
    );

    $cached_data = $this->getRenderedCache($cache_context);
    if (!empty($cached_data->data)) {
      $output = $cached_data->data;
    }
    else {
      $output = parent::view($id);

      if (!empty($output)) {
        $this->setRenderedCache($output, $cache_context);
      }
    }


    return $output;
  }

// ...

But this is not perfect because the try ... catch done in RestfulDataProviderSearchAPI\view($id) can be made too late (done after checking for cache).

To my mind the RestfulDataProviderSearchAPI\view($id) should be improved to use caching. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant