Thread-safe cache of one object in java

google collections actually supplies just the thing for just this sort of thing: Supplier Your code would be something like: private Supplier<List<String>> supplier = new Supplier<List<String>>(){ public List<String> get(){ return loadCountryList(); } }; // volatile reference so that changes are published correctly see invalidate() private volatile Supplier<List<String>> memorized = Suppliers.memoize(supplier); public List<String> list(){ return memorized.get(); … Read more

Observing stale instruction fetching on x86 with self-modifying code

I think, you should check the MACHINE_CLEARS.SMC performance counter (part of MACHINE_CLEARS event) of the CPU (it is available in Sandy Bridge 1, which is used in your Air powerbook; and also available on your Xeon, which is Nehalem 2 – search “smc”). You can use oprofile, perf or Intel’s Vtune to find its value: … Read more

How can I prevent a Dockerfile instruction from being cached?

A build-time argument can be specified to forcibly break the cache from that step onwards. For example, in your Dockerfile, put ARG CACHE_DATE=not_a_date and then give this argument a fresh value on every new build. The best, of course, is the timestamp. docker build –build-arg CACHE_DATE=$(date +%Y-%m-%d:%H:%M:%S) … Make sure the value is a string … Read more

Can you cache a virtual function lookup in C++?

There are two costs to a virtual function call: The vtable lookup and the function call. The vtable lookup is already taken care of by the hardware. Modern CPUs (assuming you’re not working on a very simple embedded CPU) will predict the address of the virtual function in their branch predictor and speculatively execute it … Read more

NGINX caching proxy fails with SSL23_GET_SERVER_HELLO:sslv3 alert handshake failure

I had the exactly same problem and spent a couple of hours… I guess you are using older version of nginx (lower than 1.7)? In nginx 1.7 you can use this directive: proxy_ssl_server_name on; This will force nginx to use SNI Also, you should set the SSL protocols: proxy_ssl_protocols TLSv1 TLSv1.1 TLSv1.2; For earlier versions … Read more