承接 orlandothoeny/memory-limiter 相关项目开发

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

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

orlandothoeny/memory-limiter

最新稳定版本:1.0.0

Composer 安装命令:

composer require orlandothoeny/memory-limiter

包简介

PHP library that can read the available memory and set limit to currently free memory

README 文档

README

Latest Stable Version PHP Version codecov PHPStan level Dependencies License Downloads

Memory Limiter is a PHP library that contains functionality to read the currently available/free memory of the system and to set the PHP memory limit according to the available memory.

Supports the following environments:

  • Bare Metal Linux
  • VM Linux
  • Kubernetes Linux container
  • Linux container (Docker, Podman, etc.)

Installation

composer require orlandothoeny/memory-limiter

Usage

Get currently available/free memory

<?php
use MemoryLimiter\AvailableMemoryReader;

$availableMemoryReader = AvailableMemoryReader::create();

$availableMemory = $availableMemoryReader->determineAvailableMemoryBytes();

Set PHP memory limit to currently available/free memory

<?php
use MemoryLimiter\MemoryLimiter;

$memoryLimiter = MemoryLimiter::create();

/* Set memory limit to the currently available memory
Will skip setting the memory limit if running inside a Kubernetes container */
$memoryLimiter->setMemoryLimitToCurrentlyAvailableMemory();

// Also set memory limit when running inside a Kubernetes container
$memoryLimiter->setMemoryLimitToCurrentlyAvailableMemory(false);

// Set memory limit to 50% of the currently available memory
$memoryLimiter->setMemoryLimitToCurrentlyAvailableMemory(
    limitToPercentageOfAvailableMemory: 50
);

Acknowledgments

  • Teleboy: Sponsored initial development

Releases

See the releases page for a list of all releases. Releases are documented in the CHANGELOG.

This project uses semantic versioning as its versioning scheme.

Development

Install pre-commit hook

rm -f .git/hooks/pre-commit
cp dev-environment/pre-commit.sh .git/hooks/pre-commit

Run locally

Prerequisites:

Start the development environment and SSH into the container

make quickstart

Separate commands

Build the container image
docker compose build
Run the container in the background
docker compose up -d
SSH into the container

Available commands:

  • php
  • composer
docker compose exec php sh
Stop the container
docker compose down

Tests

docker compose exec php composer test

PHPStan

docker compose exec php composer phpstan

Code Style

docker compose exec php composer cs-fix

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-08-09