Git Product home page Git Product logo

Comments (5)

wsargent avatar wsargent commented on August 31, 2024

Play-WS does not assume that you want to use Java serialization as your persistence mechanism. In fact, persistence isn't handled through Play-WS -- that's abstracted out to the HTTP cache trait, which is responsible for serialization:

https://github.com/playframework/play-ws/blob/master/play-ahc-ws-standalone/src/main/scala/play/api/libs/ws/ahc/cache/Cache.scala

So the problem here is that the ehcache cache has overflow to disk set to true:

https://github.com/grigoriy/play-ws-persistent-cache-bug/blob/master/source/main/resources/ehcache.xml

Instead, you can configure ehcache as follows:

https://playframework.com/documentation/2.6.x/WsCache

<ehcache
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:noNamespaceSchemaLocation="http://ehcache.org/ehcache.xsd"
        name="play-ws-cache"
        updateCheck="false"
        >

	<cache name="play-ws-cache" maxEntriesLocalHeap="10000" eternal="false"
		timeToIdleSeconds="360" timeToLiveSeconds="1000" overflowToDisk="false" />

</ehcache>

from play-ws.

grigoriy avatar grigoriy commented on August 31, 2024

Thanks for the explanation. Could you consider it as a feature request or is it completely out of the scope of Play-WS? I am willing to participate in implementing this if needed. The use case is as follows: we want to use long-term on-disk HTTP cache, adhering to RFC 5861, 7232 and 7234, which would allow our application to reuse it after the application restarts. Do you think it is feasible without (Java) serializability of responses?

from play-ws.

wsargent avatar wsargent commented on August 31, 2024

Oh, it's totally feasible. It's not something I can do myself at this point, but it's an option -- that being said, the assumption right now is that the cache is in-memory and synchronous. You can see in the README there's an example of Caffeine being used:

https://github.com/playframework/play-ws#caching

One thing that would have to be added is that Cache would have to implement Future[T] so that you could have IO thread handling behind an asynchronous boundary: #133

For serialization, I'd probably use Kryo with Chill and setRegistrationRequired: https://github.com/twitter/chill / https://github.com/EsotericSoftware/kryo#registration as it'd be faster and inline with the JVM. If you're looking for a shared cache between programs, then personally I think Avro is the best overall choice.

from play-ws.

wsargent avatar wsargent commented on August 31, 2024

It'd be best if you could do it as an sbt subproject with a dependency on the AHC implementation. I didn't do any work to break out the cache implementation or API from AHC itself, so that's another possibility.

from play-ws.

grigoriy avatar grigoriy commented on August 31, 2024

Thanks for advice Will! I'll definitely consider the options you've mentioned. Closing. Cheers, Grigoriy.

from play-ws.

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.