friendsofhyperf/session-handler

This package is not installable via Composer 1.x, please make sure you upgrade to Composer 2+. Read more about our Composer 1.x deprecation policy.

Session handler for Hyperf

dev-main 2021-06-25 09:37 UTC

This package is auto-updated.

Last update: 2021-11-25 10:52:16 UTC


README

Latest Stable Version Total Downloads GitHub license

Installation

composer require friendsofhyperf/session-handler
  • memcache
composer require huizhang/memcache
  • memcached
composer require easyswoole/memcache

Configure

  • Singleton
// config/session.php

return [
    'handler' => FriendsOfHyperf\SessionHandler\Handler\MemcacheHandler::class,
    // or
    'handler' => FriendsOfHyperf\SessionHandler\Handler\MemcachedHandler::class,
    'options' => [
        // tcp://host:port
        'path' => 'tcp://127.0.0.1:11211',
        // or
        // [host, port]
        'path' => ['127.0.0.1', 11211],
        'gc_maxlifetime' => 1200,
        'session_name' => 'HYPERF_SESSION_ID',
        'domain' => null,
        'cookie_lifetime' => 5 * 60 * 60,
    ],
];
  • Cluster
// config/session.php

return [
    'handler' => FriendsOfHyperf\SessionHandler\Handler\MemcacheHandler::class,
    // or
    'handler' => FriendsOfHyperf\SessionHandler\Handler\MemcachedHandler::class,
    'options' => [
        'cluster' => true,
        'path' => [
            // [host, port, weight]
            ['127.0.0.1', 11211, 1],
            ['127.0.0.1', 11212, 1],
        ],
        // or
        // ['tcp://host:port#weight']
        'path' => [
            'tcp://127.0.0.1:11211#1',
            'tcp://127.0.0.1:11212#1',
        ],
        'gc_maxlifetime' => 1200,
        'session_name' => 'HYPERF_SESSION_ID',
        'domain' => null,
        'cookie_lifetime' => 5 * 60 * 60,
    ],
];

Support drivers

  • Memcache
  • Memcached