Caching in drupal 7

Modules often have to make expensive database queries or calls to remote web services. Rather than
using resources for those operations every time they occur, modules can store a cache of their data into
one of the bins reserved for caching within the Drupal database, where bins are tables in the database.
Standard bins include the following:


Session-Related Settings

There are three places where Drupal modifies session-handling settings: in the .htaccess file, in the
settings.php file, and in the bootstrap code in the includes/ file.


Repository Pattern

A repository represents an architectural layer that handles communication between the application and data source. It is a widely used pattern whose main point is that the application does not have to know which data source is implemented and how it is implemented. This makes it easier to switch to another data source or implement structural changes to the existing data source.


Real world example: There can only be one president of a country at a time. The same president has to be brought to action, whenever duty calls. President here is singleton.
Purpose: To have only one instance of this object in the application that will handle all calls.

Key: To create a singleton, make the constructor private, disable cloning, disable extension and create a static variable to house the instance

A real example of Drupal 8 custom module

Create a folder within Drupal installation at the path: /modules/custom/ele_form,
within this ele_form folder, create the following files:


Drupal 8 core concepts and architecture

1. Drupal core, modules, and themes
From an architectural standpoint, we can break up Drupal into three pieces--its core,
modules, and themes.
When we discuss Drupal 8 core, we can interpret it in two ways. A more restrictive
interpretation sees it as a functionality covered in all the code it ships with, without
modules and themes. The more widespread interpretation sees it as the total code base it
ships with (out of the box).


Example for creating a custom module

There are two general categories of Drupal modules—core and contributed. Core modules are those
that are shipped with Drupal and include modules such as polls, menus, taxonomy, search, feed
aggregator, and forums. Contributed modules are all of the modules created by the community that
extend and enhance the functional footprint of Drupal core. There are literally thousands of contributed
modules available for download at


Deployments and Architectures

The architectures available for Drupal are those of other LAMP-stack software, and the techniques used
to scale are applicable to Drupal as well. Thus, we’ll concentrate on the Drupal-specific tips and gotchas
for different architectures.


Areas for improving Drupal performance

There are several often overlooked areas for improving Drupal performance that are simple to implement.


Enabling MySQL’s Query Cache

MySQL is the most common database used with Drupal. MySQL has the ability to cache frequent queries
in RAM so that the next time a given query is issued, MySQL will return it instantly from the cache.
However, in most MySQL installations, this feature is disabled by default. To enable it, add the following
lines to your MySQL option file; the file is named my.cnf and specifies the variables and behavior for
your MySQL server In this case,
we’re setting the query cache to 64MB:



Subscribe to Front page feed