承接 darkotodoric/efficient-file-management 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

darkotodoric/efficient-file-management

最新稳定版本:v1.0

Composer 安装命令:

composer require darkotodoric/efficient-file-management

包简介

PHP-based file management system designed for seamless storage and retrieval of large volumes of files with optimal performance

README 文档

README

Packagist License Packagist Version

The EfficientFileManagement class is a highly efficient PHP solution for managing and storing an extensive number of files, potentially in the order of billions, while maintaining exceptional performance. It achieves this scalability by organizing files into a hierarchical folder structure based on unique IDs (from database or any other source) and file extensions.

Installation

Install the latest version with:

$ composer require darkotodoric/efficient-file-management

Usage

require_once 'vendor/autoload.php';

// Define the folder path where files will be saved
$baseFolderPath = '/mnt/efficient-file-management/';

// Define allowed extensions
$allowedExtensions = ['json', 'xml', 'txt'];

// Define the division number (Maximum number of files in one folder)
$divisionNumber = 50000;

$efficientFileManagement = new EfficientFileManagement($baseFolderPath, $allowedExtensions, $divisionNumber);

// Get IDs from MySQL or other data source
$ids = [1337, 5162, 70312, 155312, 160312, 525312];

// Save content
foreach ($ids as $id) {
    $data = json_encode(['name' => 'File with ID ' . $id]);
    $efficientFileManagement->saveContent($id, 'json', $data);
}

// Get content
foreach($ids as $id){
    $data = $efficientFileManagement->getContent($id, 'json');
}

// Delete content
foreach($ids as $id){
    $data = json_encode(['name' => 'File with ID ' . $id]);
    $efficientFileManagement->deleteContent($id, 'json');
}

Folder and file structures

Here's an example of how the folder structure and files might look when using the EfficientFileManagement class to store files with IDs and extensions: Suppose we have the following files:

  • File with ID 123456, 987654, 555555 and extension json
  • File with ID 987654 and extension xml
  • File with ID 555555 and extension txt

The resulting folder structure might look like this:

/mnt/efficient-file-management/
    ├── json/
    │   ├── 2/
    │   │   └── 123456.json
    │   ├── 19/
    │   │   └── 987654.json
    │   ├── 11/
    │   │   └── 555555.json
    ├── xml/
    │   ├── 19/
    │   │   └── 987654.xml
    ├── txt/
    │   ├── 11/
    │   │   └── 555555.txt

In this structure:

  • Files with the .json extension are stored in the json folder.
  • Files with the .xml extension are stored in the xml folder.
  • Files with the .txt extension are stored in the txt folder.
  • Each folder is further organized into subfolders based on the integer division of the file's ID by 50000. This hierarchical organization ensures that even with a vast number of files, the system remains efficient and easily manageable.

Contributing

Contributions are welcome! Feel free to open issues or submit pull requests to improve this project.

统计信息

  • 总下载量: 3
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 2
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 2
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-01-12