Cache Management Directives

Ahmed PHP Template Engine provides multiple directives to manage caching: @setCache, @getCache, @updateCache, and @deleteCache.

@setCache - Store Data in Cache

Syntax

@setCache(key, value, minutes)
  • key: The cache identifier.

  • value: The data to store.

  • minutes: (Optional) Expiration time in minutes.

Example

@setCache("user_profile", {"name": "Ahmed", "email": "ahmed@example.com"}, 60)

@getCache - Retrieve Cached Data

Syntax

@getCache(key)
  • key: The cache identifier.

Example

@var(user, @getCache("user_profile"))
<p>Name: @user["name"]</p>
<p>Email: @user["email"]</p>

@updateCache - Modify Cached Data

Syntax

  • key: The cache identifier.

  • value: The new data to store.

Example

@deleteCache - Remove Cached Data

Syntax

  • key: The cache identifier.

Example

Notes

  • @setCache stores data for a specified duration (default is unlimited if minutes is omitted).

  • @getCache retrieves cached values.

  • @updateCache modifies existing cache entries.

  • @deleteCache removes specific cache entries.

Last updated