configuration – Set disabled cache but it’s not working

In /sites/default/settings.local.php make sure you have

$settings['container_yamls'][] = DRUPAL_ROOT . '/sites/';

You need to go to /sites/ and turn off Twig’s cache by adding

    twig.config: { debug: true, auto_reload: true, cache: false }

This is what mine looks like:

# Local development services.
# To activate this feature, follow the instructions at the top of the
# 'example.settings.local.php' file, which sits next to this file.
    twig.config: { debug: true, auto_reload: true, cache: false }
    http.response.debug_cacheability_headers: true
    class: DrupalCoreCacheNullBackendFactory

For more info, see Disable Drupal 8 caching during development

microservices – Where to place an in-memory cache to handle repetitive bursts of database queries from several downstream sources, all within a few milliseconds span

I’m working on a Java service that runs on Google Cloud Platform and utilizes a MySQL database via Cloud SQL. The database stores simple relationships between users, accounts they belong to, and groupings of accounts. Being an “accounts” service, naturally there are many downstreams. And downstream service A may for example hit several other upstream services B, C, D, which in turn might call other services E and F, but because so much is tied to accounts (checking permissions, getting user preferences, sending emails), every service from A to F end up hitting my service with identical, repetitive calls. So in other words, a single call to some endpoint might result in 10 queries to get a user’s accounts, even though obviously that information doesn’t change over a few milliseconds.

So where is it it appropriate to place a cache?

  1. Should downstream service owners be responsible for implementing a cache? I don’t think so, because why should they know about my service’s data, like what can be cached and for how long.

  2. Should I put an in-memory cache in my service, like Google’s Common CacheLoader, in front of my DAO? But, does this really provide anything over MySQL’s caching? (Admittedly I don’t know anything about how databases cache, but I’m sure that they do.)

  3. Should I put an in-memory cache in the Java client? We use gRPC so we have generated clients that all those services A, B, C, D, E, F use already. Putting a cache in the client means they can skip making outgoing calls but only if the service has made this call before and the data can have a long-enough TTL to be useful, e.g. an account’s group is permanent. So, yea, that’s not helping at all with the “bursts,” not to mention the caches living in different zone instances. (I haven’t customized a generated gRPC client yet, but I assume there’s a way.)

I’m leaning toward #2 but my understanding of databases is weak, and I don’t know how to collect the data I need to justify the effort. I feel like what I need to know is: How often do “bursts” of identical queries occur, how are these bursts processed by MySQL (esp. given caching), and what’s the bottom-line effect on downstream performance as a result, if any at all?

I feel experience may answer this question better than finding those metrics myself.

Asking myself, “Why do I want to do this, given no evidence of any bottleneck?” Well, (1) it just seems wrong that there’s so many duplicate queries, (2) it adds a lot of noise in our logs, and (3) I don’t want to wait until we scale to find out that it’s a deep issue.

java – How to interact with cache for session state?

We are writing Java APIs and use a cache to store session state to avoid sticky sessions.

The current application code interacts with the cache whenever it needs to read or write cache data e.g. if you are 3 calls deep a method can directly interact with the cache to get customer data with no need to state in the method signature anything about customer data. Alternatively the method can write to the cache e.g. customer data it has retrieved with no mention of customer data in the return type (e.g. the return can be void here).

I think this approach:

Makes it very hard to control cache IO
Hides the data that methods are using & hence makes the application harder to understand
Makes the use of a cache intrinsic in our application, making it much harder to remove the cache at a later date.

An option we are considering is adding a Session class which interfaces to the cache. Applications would extend the Session class & pass the Session or attributes of session around. This would force methods to declare the data they use & abstract the use of the cache from the application code.

Was wondering what other peoples thoughts were on the two options,or other options?

Session variable and cache drupal

I’ve created a small helper where I can set and access my session variable (thanks to the drupal 8 session).

Can’t figure out why, my session is working well with my dev (no cache) but on my prod my session is not persisted, need to refresh drupal cache to see my session variable…

  public static function getSessionIRA()
    return self::getModuleStore()->get('session_ira');

  public static function setSessionIRA($session_ira)
    return self::getModuleStore()->set('session_ira', $session_ira);

   * @return mixed
  private static function getModuleStore()
    return Drupal::request()->getSession();

    return self::$module_store = Drupal::service('user.private_tempstore')->get('mymodule_services');

environment variables – Ruby Gem Change SPEC CACHE DIRECTORY from non-existing disk to path

When trying to install a gem i receive an error:

ERROR: While executing gem... (Errno:ENXIO)
No such device or address @ rb_file_s_stat - Z:/

when checking the gem environment variables i get the following return:

C:Program Files (x86)SOME_FOLDERRubybin>gem environment
RubyGems Environment:
  - RUBY VERSION: 2.3.1 (2016-04-26 patchlevel 112) (x64-mingw32)
  - INSTALLATION DIRECTORY: C:/Program Files (x86)/SOME_FOLDER/Ruby/lib/ruby/gems/2.3.0
  - RUBY EXECUTABLE: "C:/Program Files (x86)/SOME_FOLDER/Ruby/bin/ruby.exe"
  - EXECUTABLE DIRECTORY: C:/Program Files (x86)/SOME_FOLDER/Ruby/bin
  - SPEC CACHE DIRECTORY: Z:/.gem/specs
    - ruby
    - x64-mingw32
     - C:/Program Files (x86)/SOME_FOLDER/Ruby/lib/ruby/gems/2.3.0
     - :update_sources => true
     - :verbose => true
     - :backtrace => false
     - :bulk_threshold => 1000
     - C:Program Files (x86)Common FilesOracleJavajavapath
     - C:Windowssystem32
     - C:Windows
     - C:WindowsSystem32Wbem
     - C:WindowsSystem32WindowsPowerShellv1.0
     - C:WindowsSystem32OpenSSH
     - C:Program FilesTortoiseSVNbin
     - C:UsersrekenmtAppDataLocalMicrosoftWindowsApps

the problem is clear: USER INSTALLATION DIRECTORY and SPEC CACHE DIRECTORY are not valid paths (Z:/ disk does not exist.) the question therefore is:

how do i change those variables to point to another path

Thank you in advance

plugins – Cache WP remote_get HTTP Response using Transients

Using wp_remote_get keeps pinging the API on every page load. Which increase the server resource.

Is it possible to cache the response of the API store it using Transients and use it for next 5 minutes instead of keep pinging everytime?

And After 5 Minutes it should send request again and rewrite the stored value.

Here is my code for API Request. How to do this? I’m new to this. Help me please

function display_api_response() {
    $api_url = "";
$response = wp_remote_get($api_url);
   if ( 200 === wp_remote_retrieve_response_code($response) ) {
        $body = wp_remote_retrieve_body($response);

        if ( 'a' === $body ) {
          echo 'A wins';
        }else {
          // Do something else.
add_action( 'init', 'display_api_response' );

bash – Clearing Chrome’s DNS cache from the terminal

I have written a script to add websites to the hostfile at certain times of the day. For example, it can block Youtube from 8pm – 10pm. It works well, however the changes aren’t reflected in Chrome. This has something to do with internal DNS caching in Chrome and seemingly cannot be flushed without going into Chrome’s settings or restarting the browser.

Is there any way to flush this cache from the terminal?

hooks – Clear entity cache before render

I secured some file in an s3 bucket using s3fs.
My problem is : the “Expires” argument send to build the file URI is not reset each time the object is call in my API.

time doesn’t change if I don’t clear the cache with drush

$expires = time() + 10;

So I tried to use hook_entity_view :

if ($entity->bundle() === 'my_bundle') {
    foreach ($entity->getCacheTags() as $tag) {
      $tags() = $tag;

Doesn’t work




deleteAll or invalidateAll, none of it work.


Nothing, I’m starting to think I have config problem…
If someone can save me !