// Initiate Cache $cache = new Cache(); // Add data to cache $cache->set('name', 'John'); // Delete data from cache $cache->delete('name');
// Using cache provided by Symfony library use Symfony\Component\Cache\Adapter\FilesystemAdapter; // Initiate Cache $cache = new FilesystemAdapter(); // Add data to cache // This data will be cached for 1 hour $cache->set('name', 'John', 3600); // Delete data from cache $cache->deleteItem('name');In the first example, we have a custom cache class with a `delete()` method that accepts a key to delete the cached data. In the second example, we are using the Symfony library's cache functionality. We are using the `FilesystemAdapter` which stores cache data in the file system. We can set an expiry time for cache data and delete it using the `deleteItem()` method. In the second example, the package library used is the Symfony cache component library.