Repository Pattern – Caching

It’s a good idea not to put the caching logic directly into your repository, as that violates the Single Responsibility Principle (SRP) and Separation of Concerns. SRP essentially states that your classes should only have one reason to change. If you conflate the concerns of data access and caching policy in the same class, then … Read more

Un-persisting all dataframes in (py)spark

Spark 2.x You can use Catalog.clearCache: from pyspark.sql import SparkSession spark = SparkSession.builder.getOrCreate … spark.catalog.clearCache() Spark 1.x You can use SQLContext.clearCache method which Removes all cached tables from the in-memory cache. from pyspark.sql import SQLContext from pyspark import SparkContext sqlContext = SQLContext.getOrCreate(SparkContext.getOrCreate()) … sqlContext.clearCache()

is Rails.cache purged between tests?

A more efficient (and easier) method is to set the test environment’s cache to use NullStore: # config/environments/test.rb: config.cache_store = :null_store The NullStore ensures that nothing will ever be cached. For instance in the code below, it will always fall through to the block and return the current time: Rails.cache.fetch(‘time’) { Time.now } Also see … Read more

What happens to SDWebImage Cached Images in my app when the image file on the server changes?

I had a look at the source code. It processes the setImageWithURL method like this: Ask the memory cache if the image is there, if yes return the image and don’t go any further Ask the disk cache if the image is there, if yes return the image and don’t go any further Try to … Read more

Symfony: Clear doctrine cache

For Symfony 3+: php bin/console will list all commands, the following are relevant for cache: php bin/console doctrine:cache:clear-metadata php bin/console doctrine:cache:clear-query php bin/console doctrine:cache:clear-result Before Symfony 3: app/console will list how you can do it app/console doctrine:cache:clear-metadata app/console doctrine:cache:clear-query app/console doctrine:cache:clear-result

How to cache Google map tiles for offline usage?

If you are trying to cache the tiles that Google serves, that may be a violation of Google’s Terms of Service (unless, under certain circumstances, if you’ve purchased their enterprise Maps API Premier). That’s why gmapcatcher has it crossed off their list. See http://code.google.com/p/gmapcatcher/issues/detail?id=210. At the gmapcatcher URL above, you will also find a shell … Read more

Android Volley + JSONObjectRequest Caching

See this answer – Set expiration policy for cache using Google’s Volley This means Volley decides whether to cache response or not based only on headers “Cache-Control” and then “Expires”, “maxAge”. What you could do is change this method com.android.volley.toolbox.HttpHeaderParser.parseCacheHeaders(NetworkResponse response) and ignore these headers, set entry.softTtl and entry.ttl fields to whatever value works for … Read more

Can one cache and secure a REST API with Cloudflare?

Cloudflare has published a list of best practices for using it with APIs. TL;DR, they recommend setting a page rule that patches all API requests and putting the following settings on it: Cache Level: Bypass Always Online: OFF Web Application Firewall: OFF Security Level: Anything but “I’m under attack” Browser Integrity Check: OFF