Winter Data Memcache: Memcached Client Module
Winter Data Memcache is a module that provides easy configuration and access to Memcached service from Winter Boot applications. It supports both the memcached and memcache PHP extensions through dedicated templates.
composer require suvera/winter-modulesAppend the following code to your application.yml:
modules: - module: 'dev\winterframework\data\memcache\MemcacheModule' enabled: true configFile: memcache-config.ymlImplementation
Section titled “Implementation”PHP has two very good libraries that can be used to work with Memcache:
One of these extensions is required.
pecl install memcached
pecl install memcacheAutowired Services
Section titled “Autowired Services”This module provides the following services automatically available to you.
1. MemcachedTemplate
Section titled “1. MemcachedTemplate”Available when the memcached PHP extension is installed.
2. MemcacheTemplate
Section titled “2. MemcacheTemplate”Available when the memcache PHP extension is installed.
Configuration (memcache-config.yml)
Section titled “Configuration (memcache-config.yml)”# When **memcache** php extension installed.memcache: - name: bean01 idleTimeout: 30 timeout: 0 retry_interval: 0 status: 0 servers: - host: 127.0.0.1 port: 11211 weight: 0
# When **memcached** php extension installed.memcached: - name: bean02 timeout: 0 idleTimeout: 30 retry_interval: 0 status: 0 servers: - host: 127.0.0.1 port: 11211 weight: 0PHP Example
Section titled “PHP Example”#[Autowired("bean02")]private MemcachedTemplate $memcache1;
#[Autowired("bean01")]private MemcacheTemplate $memcache2;