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

Provide compatibility with CacheInterface #6

Open
2 of 6 tasks
shgysk8zer0 opened this issue Jun 8, 2020 · 2 comments
Open
2 of 6 tasks

Provide compatibility with CacheInterface #6

shgysk8zer0 opened this issue Jun 8, 2020 · 2 comments
Assignees
Labels
backlog Issue that are held-back until later enhancement New feature or request

Comments

@shgysk8zer0
Copy link
Owner

shgysk8zer0 commented Jun 8, 2020

Check that Requests & Responses are the same before and after serialize() & unserialize().

In other words:

<?php
$req = new Request();
$resp = new Response();
/**
 * Build up $req & $resp
 */

unserialize(serialize($req)); // Same as original Request?
unserialize(serialize($resp)); // Same as original Response?

One issue that I suspect difficulty in encountering is whether or not CURLFile can be serialized. I could easily create a custom class that just serializes the filename, type, & postname, but cannot guarantee that the file will still exist when unserialized.

Tasks:

  • Ensure compatibility with serialize() & unserialize() for caching
  • Determine cache keys from request URL & probably Accept & Vary headers
  • Implement a serializable file class extending CURLFile
  • Determine method of setting expiration for cache (response headers, maybe?)
  • Handle caching by an init preference, similar to JS's Request.cache preference
  • Update example in README.md
@shgysk8zer0 shgysk8zer0 self-assigned this Jun 8, 2020
@shgysk8zer0 shgysk8zer0 added the enhancement New feature or request label Jun 8, 2020
@shgysk8zer0 shgysk8zer0 changed the title Test compatibility with CacheInterface Provide compatibility with CacheInterface Jun 8, 2020
@shgysk8zer0
Copy link
Owner Author

Perhaps I could provide cache key using Request::__toString(), allowing:

if ($cache->has($req)) {
    $resp = $cache->get($req);
}

Request could then provide methods taking expiration & fallback args and work somewhat more directly with CacheInterface.

@shgysk8zer0
Copy link
Owner Author

Due to the complexity of HTTP caching, I do not think that the basic CacheInterface can be compatible. I need to be able to check ETags, make conditional requests, utilize Cache-Control headers, etc.

@shgysk8zer0 shgysk8zer0 added the backlog Issue that are held-back until later label Jun 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backlog Issue that are held-back until later enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant