[font="Times New Roman"][size="3"]Hi[/size][/font]
[font="Times New Roman"][size="3"]I write below code in one actionController for caching query of database in memcached:[/size][/font]
[font=“Times New Roman”][size=“3”][color="#ff0000"]$key = ‘my_key’;[/color][/size][/font]
[font="Times New Roman"][size="3"][color="#ff0000"] $post = \Yii::$app->cache->get($key);[/color][/size][/font]
[font="Times New Roman"][size="3"][color="#ff0000"] if ($post === false) {[/color][/size][/font]
[font=“Times New Roman”][size=“3”][color="#ff0000"] $post =\backend\models\Post::find()->where([‘id’=>3])->one();[/color][/size][/font]
[font="Times New Roman"][size="3"][color="#ff0000"] \Yii::$app->cache->set($key, $post,5); // time in seconds to store cache[/color][/size][/font]
[font="Times New Roman"][size="3"][color="#ff0000"] echo "data not in cache";[/color][/size][/font]
[font="Times New Roman"][size="3"][color="#ff0000"] }[/color][/size][/font]
[font="Times New Roman"][size="3"][color="#ff0000"] else[/color][/size][/font]
[font="Times New Roman"][size="3"][color="#ff0000"] {[/color][/size][/font]
[font="Times New Roman"][size="3"][color="#ff0000"] echo "<pre>";[/color][/size][/font]
[font="Times New Roman"][size="3"][color="#ff0000"] print_r($post);[/color][/size][/font]
[font="Times New Roman"][size="3"][color="#ff0000"] echo "data in cache";[/color][/size][/font]
[font="Times New Roman"][size="3"][color="#ff0000"] }[/color][/size][/font]
[font="Times New Roman"][size="3"]The cache work correctly,but the cache duration is not work correct(after 5 second cache in not deleted).[/size][/font]
[font="Times New Roman"][size="3"]Please help me?[/size][/font]