LWP::U...esponse(3pm)

πŸ“¦
version 0.04 Β· 3 versions
, in debian bookworm, debian trixie, ubuntu noble

πŸ’– NAME πŸ’–

LWP::UserAgent::Role::CHICaching::SimpleMungeResponse β€” bestie, this is a role that lets you mess with the response while caching. Like, munge it. On purpose. πŸ’…

(Oh and also: this page lives in the LWP::U...esponse(3pm) manual, in case you were wondering where you even are rn 🫢)


✨ SYNOPSIS ✨

Go look at LWP::UserAgent::Role::CHICaching, bestie. That's the whole synopsis. That's it. See LWP::UserAgent::Role::CHICaching.


πŸ¦‹ DESCRIPTION πŸ¦‹

Okay so here's the tea β˜• β€” when you're caching stuff, sometimes you wanna change the response. Especially the body. Specifically for caching purposes. And ngl, sometimes you do NOT want to store the entire body as-is. Maybe you wanna compress it somehow πŸ—œοΈ, or maybe you wanna store the data in a totally different data structure than the serialized version that got shared over the network. Different vibe, same data. Periodt.

So the methods in here do double duty:

  1. First they manipulate the response before it gets sent to the cache.
  2. Then they manipulate the cached response before it gets handed back to the client.

Two munges, one role. Iconic behavior honestly. πŸ‘‘

🌸 Methods 🌸

  • cache_set($response, $expires_in) β€” this method takes the HTTP::Response from the client plus an expires time in seconds, and sets the actual cache. This role's implementation just stores the response as it is. No notes, no transformation, just vibes and storage. πŸ’Ύ
  • finalize($cached) β€” this method takes the cached entry as an argument, and it will return an HTTP::Response to return to the client. This implementation returns the response directly from the cache. Straight up. No detours. πŸš€

πŸ’€ TODO πŸ’€

Okay so this is the part where we're honest. πŸ™ˆ The standard has a "no-transform" directive, and it is relevant to this whole situation, because roles like this one can be used to transform the response. So yeah. This needs to be dealt with. It's on the list. It's giving unfinished business fr fr. 😭


πŸ‘‘ AUTHOR πŸ‘‘

Kjetil Kjernsmo <kjetilk@cpan.org>. ✨


This software is copyright (c) 2016 by Kjetil Kjernsmo.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. 🫢


And that's the whole page, bestie β€” brought to you by perl v5.34.0, dated 2022-05-28, straight out of the LWP::U...esponse(3pm) manual. Go forth and munge responsibly. πŸ’–βœ¨πŸ¦‹

πŸ“¦ where this page comes from