承接 b3it/laravel-memcached-plus 相关项目开发

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

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

b3it/laravel-memcached-plus

最新稳定版本:4.1

Composer 安装命令:

composer require b3it/laravel-memcached-plus

包简介

Extends the built-in Laravel 5 Cache Memcached driver adding support for persistent connections, SASL and Memcached options.

README 文档

README

StyleCI Build Status Total Downloads Latest Stable Version Latest Unstable Version License

Summary

This package is useful for Laravel 5.0 - 5.2. From 5.3 onwards two PRs I submitted to laravel/framework have been merged, therefore the features of this package are available out-the-box with Laravel 5.3 onwards.

Integrating with cloud memcached services such as MemCachier and memcached cloud can require memcached features not available with the built-in Laravel Cache memcached driver from version 5.0 to 5.2.

These include:

  • SASL authentication
  • custom options
  • persistent connections

Adding 3 new configuration items, this package enhances the built-in Laravel 5 Cache memcached driver. Optionally, this package also allows these extra configuration items to be used for memcached Sessions.

Read on for detailed instructions - you may find it useful to reference the demo app at the same time.

Requirements

Installation

Available to install as a Composer package on Packagist, all you need to do is:

composer require b3it/laravel-memcached-plus

If your local environment does not meet the requirements you may need to append the ignore-platform-reqs option:

composer require b3it/laravel-memcached-plus --ignore-platform-reqs

Configuration

Once installed you can use this package to enhance the Laravel Cache and Session services.

Providers

This section discusses the Laravel application configuration file app/config.php.

In the providers array you need to replace following built-in Service Providers:

  • Illuminate\Cache\CacheServiceProvider and
  • Illuminate\Session\SessionServiceProvider (optional)

A recommended approach is to comment out the built-in providers and append the Service Providers from this package:

'providers' => [
    ...
    //'Illuminate\Cache\CacheServiceProvider',
    ...
    //'Illuminate\Session\SessionServiceProvider',
    ...

    /*
     * Application Service Providers...
     */
     ...

    'B3IT\MemcachedPlus\CacheServiceProvider',
    'B3IT\MemcachedPlus\SessionServiceProvider', // optional
],

The B3IT\MemcachedPlus\SessionServiceProvider is optional. You only need to add this if:

  • You want to specify a non-default memcached store to use for sessions, default is "memcached", or
  • You want to use the memcached features provided by this package for sessions

Cache

This section discusses the Laravel cache configuration file config/cache.php.

This package makes the following extra configuration items available for use with a memcached store:

These may be used in a store config like so:

'stores' => [
    'memcachedstorefoo' => [
        'driver'  => 'memcached',
        'persistent_id' => 'laravel',
        'sasl'       => [
            env('MEMCACHIER_USERNAME'),
            env('MEMCACHIER_PASSWORD')
        ],
        'options'    => [
            Memcached::OPT_NO_BLOCK         => true,
            Memcached::OPT_AUTO_EJECT_HOSTS => true,
            Memcached::OPT_CONNECT_TIMEOUT  => 2000,
            Memcached::OPT_POLL_TIMEOUT     => 2000,
            Memcached::OPT_RETRY_TIMEOUT    => 2,
        ],
        'servers' => [
            [
                'host' => '127.0.0.1', 'port' => 11211, 'weight' => 100
            ],
        ],
    ],
],

Note that as this package enhances the built-in Laravel 5 memcached Cache driver, the driver string remains memcached.

In case you are unfamiliar with how to use multiple cache stores in Laravel, you would access this store from your application code like so:

$value = Cache::store('memcachedstorefoo')->get('key');

Session

This section discusses the Laravel session configuration file config/session.php.

If you are using memcached sessions you will have set the driver configuration item to 'memcached'.

If you have added the B3IT\MemcachedPlus\SessionServiceProvider as discussed above, the store configuration item is available. This is explained in the following new snippet you can paste into your session configuration file:

    /*
    |--------------------------------------------------------------------------
    | Session Cache Store
    |--------------------------------------------------------------------------
    |
    | When using the "apc" or "memcached" session drivers, you may specify a
    | cache store that should be used for these sessions. This value must
    | correspond with one of the application's configured cache stores.
    |
    */

    'store' => null,

To use the previous memcached 'plus' store example with sessions you would set this as follows:

    'store' => 'memcachedstorefoo',

Breaking changes between v3 and v4

The configuration of Memcached options has been updated to use the Memcached constants rather than the string constant name.

The session.memcached_store variable has been renamed to session.store.

laravel-memcached-plus in action

I created a demo app for you to see how this package integrates with Laravel 5 and how you could run it on Heroku.

Support

Please do let me know if you have any comments or queries.

Thanks!

b3it/laravel-memcached-plus 适用场景与选型建议

b3it/laravel-memcached-plus 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 56.4k 次下载、GitHub Stars 达 15, 最近一次更新时间为 2015 年 03 月 04 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「cache」 「options」 「memcached」 「laravel」 「sasl」 「persistent」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 b3it/laravel-memcached-plus 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 b3it/laravel-memcached-plus 我们能提供哪些服务?
定制开发 / 二次开发

基于 b3it/laravel-memcached-plus 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 56.4k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 15
  • 点击次数: 23
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 15
  • Watchers: 2
  • Forks: 9
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-03-04