Get the App
SLTechnology News&Howtos  ›  Servers  › 

Distributed memcache

Shulou Source: shulou.com Published: 2022-06-03 07:00:48 09月21日 Update

Operate memcache under php:

1. Connect to the memcache server

$mem=new Memcache

$mem- > addServer ("192.168.0.1", "11211")

two。 Increase

$mem- > set ('name','user1')

3. Delete

$mem- > delete ('name')

4. Change

$mem- > set ('age',200)

5. Check

Echo $mem- > get ('age')

6. View statu

$arr=$mem- > getStats ()

7. Empty

$mem- > flush ()

[example: php+memcache caches dynamic data]

[example: cross-domain login of php+memcache users]

Php saves session to a shared memcache server when the user logs in:

[Session]

1.session.save_handler = memcache

2.session.save_path = "tcp://192.168.0.1:11211"

Tags: Instance server user service login dynamic data state cache distributed Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Technology MySQL Huawei vpn Microsoft