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
@setCachestores data for a specified duration (default is unlimited ifminutesis omitted).@getCacheretrieves cached values.@updateCachemodifies existing cache entries.@deleteCacheremoves specific cache entries.
Last updated