PHP code example of betorcs / file-store
1. Go to this page and download the library: Download betorcs/file-store library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
betorcs / file-store example snippets
$fileContent = ...
$baseDir = '/tmp';
$fileStore = new \Betorcs\LocalFileStore($baseDir);
// Saves a file content with expiration of 120 seconds, then returns a key.
$key = $fileStore->store($fileContent, 120);
// Deletes all expired contents
$fileStore->deleteAllExpired();
// Checkes if exists a non expired content
if ($fileStore->exists($key))
{
// It's TRUE if exists
}
// Retrieve a content from given key, if it exists and non expired
$content = $fileStore->restore($key);
// Deletes all contents
$fileStore->clean();