Save a temporary data - Key Value Expirable. | Drupal 8

Save a temporary data - Key Value Expirable.

Submitted by editor on Fri, 02/09/2018 - 13:53
Question

How to save a variable temporarily on drupal 8 ?
How to use keyvalue.expirable service ?

 

keyvalue.expirable service allow to save Key / Value variable in the database.

Example:

// Save without date limit.
\Drupal::service('keyvalue.expirable')->get('my_module')->set('my_var', 123);

// Save for 1 day.
\Drupal::service('keyvalue.expirable')->get('my_module')->setWithExpire('time', time(), 86400);

Read data:
$my_var = \Drupal::service('keyvalue.expirable')->get('my_module')->set('my_var', $default_value);

Example 2:
$keyvalues = \Drupal::service('keyvalue.expirable')->get('my_module');
$keyvalues->set('name', 'The name');
$name = $keyvalues->get('name');

 

Tags

Comments

R HILDAN M (not verified)

Fri, 12/14/2018 - 17:02

link 9 agen astm a283 c agen pipa boiler agen plat abrex 400 agen plat asme516 grade70 agen plat astm a285 c agen plat astm516 70 agen plat boiler agen plat hardox agen plat hb 400 agen plat high strenght agen plat high tensile sm490 yb agen plat high tensile sm490ya agen plat kapal agen plat stainless ss304 agen plat stainless ss310 agen plat stainless ss316 agen plat sumihard agen round bar besi aisi 440s45c agen round bar scm440 agen steel rail agen steel sheet pile distributor astm a283 c distributor pipa boiler distributor plat abrex 400 distributor plat asme516 grade70 distributor plat astm a285 c distributor plat astm516 70 distributor plat boiler distributor plat hb 400 distributor plat high strenght distributor plat high tensile sm490 yb distributor plat high tensile sm490ya distributor plat kapal distributor plat stainless ss304 distributor plat stainless ss310 distributor plat stainless ss316 distributor plat sumihard distributor round bar besi aisi 440s45c distributor round bar scm440 distributor steel rail distributor steel sheet pile jual astm a283 c jual baja h beam jual pipa boiler jual plat abrex 400 jual plat asme516 grade70 jual plat astm a285 c jual plat astm516 70 jual plat boiler jual plat hardox jual plat hb 400 jual plat high strenght jual plat high tensile sm490 yb jual plat high tensile sm490ya jual plat kapal jual plat stainless ss304 jual plat stainless ss310 jual plat stainless ss316 jual plat sumihard jual round bar besi aisi 440s45c jual round bar scm440 jual steel rail jual steel sheet pile pabrik astm a283 c pabrik pipa boiler pabrik plat abrex 400 pabrik plat asme516 grade70 pabrik plat astm516 70 pabrik plat boiler pabrik plat hb 400 pabrik plat high tensile sm490 yb pabrik plat high tensile sm490ya pabrik plat kapal pabrik plat stainless ss304 pabrik plat stainless ss310 pabrik round bar besi aisi 440s45c pabrik round bar scm440 pabrik steel rail pabrik steel sheet pile pusat astm a283 c pusat pipa boiler pusat plat abrex 400 pusat plat asme516 grade70 pusat plat astm a285 c pusat plat astm516 70 pusat plat boiler pusat plat hardox pusat plat hb 400 pusat plat high strenght pusat plat high tensile sm490 yb pusat plat high tensile sm490ya pusat plat kapal pusat plat stainless ss304 pusat plat stainless ss310 pusat plat stainless ss316 pusat plat sumihard pusat round bar besi aisi 440s45c pusat round bar scm440 pusat steel rail pusat steel sheet pile stockis plat hardox stockist plat astm a285 c stockist plat high strenght stockist plat stainless ss316 stockist plat sumihard supplier plat hardox

Add new comment