定制 ride/lib-varnish 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

ride/lib-varnish

最新稳定版本:1.0.2

Composer 安装命令:

composer require ride/lib-varnish

包简介

Varnish library of the Ride framework.

README 文档

README

Varnish library of the PHP Ride framework.

What's In This Library

VarnishServer

The VarnishServer interface is used to manipulate a single Varnish server or a pool of servers transparantly.

VarnishAdmin

The VarnishAdmin class connects to a single Varnish server directly to send commands.

VarnishPool

The VarnishPool class can be used to create a pool of different VarnishAdmin instances. All commands of the VarnishServer interface will be invoked on all available servers in the pool.

Code Sample

Check this code sample to see some of this library's functionality:

<?php

use ride\library\varnish\exception\V arnishException;
use ride\library\varnish\VarnishAdmin;
use ride\library\varnish\VarnishPool;

try {
    // create a single server
    $varnish = new VarnishAdmin('localhost', 6082, 'your-secret');
    
    // check if worker process is running
    $varnish->isRunning(); // true | false
    
    // start the cache process, this will call isRunning() internally
    $varnish->start();
    
    // stop the cache process, this will call isRunning() internally
    $varnish->stop();
    
    // ban with a URL and everything underneath it
    $varnish->banUrl('http://example.com/path', true);
    
    // ban with an expression
    $varnish->ban('req.http.host == "example.com" && req.url == "/path/to/page"');
    
    // create a pool of servers
    $pool = new VarnishPool();
    $pool->addServer($varnish);
    $pool->addServer(new VarnishAdmin('example.com', 6082, 'sneaky sneaky');
    
    // ban with a URL or with an expression on all servers
    $pool->banUrl('http://example.com/path');
    $pool->ban('req.http.host == "example.com" && req.url == "/path/to/page"');
} catch (VarnishException $exception) {
    // something went wrong
}

Implementations

For more examples, you can check the following implementations of this library:

Installation

You can use Composer to install this library.

composer require ride/lib-varnish

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-02-27