Skip to content

Winter Memdb: Embedded In-Memory Database Module

Winter Memdb runs embedded in-memory database engines (Redis, Apache Ignite, Memcached, and Hazelcast) as part of the application lifecycle, auto-starting on boot and stopping on shutdown.

This module requires the swoole PHP extension.

Install the package:

Terminal window
composer require suvera/winter-memdb

Enable the module in application.yml:

modules:
- module: dev\winterframework\memdb\MemdbModule
enabled: true
configFile: memdb-config.yml

configFile is a file path (relative to the config directory or an absolute path).

The configuration file can define any number of engines, each with its own top-level key:

# Redis
redis:
# Redis Configuration here, see below section
# Apache Ignite
ignite:
# Apache Ignite Configuration here
# Memcached
memcached:
# Memcached Configuration here
# Hazelcast
hazelcast:
# Hazelcast Configuration here
redis:
- name: redisServerBean01
serverBinary: /usr/local/bin/redis-server
confFile: redis_1.conf # relative or absolute path
args: ""

Many server configurations are allowed. Client beans are auto-created by the framework using the given name, for example redisServerBean01.

#[Autowired('redisServerBean01')]
private PhpRedisTemplate $redis;
ignite:
- name: igniteServerBean01
serverBinary: /etc/apache-ignite-2.10.0/bin/ignite.sh
# Optional config
confFile: ignite-config.xml # relative or absolute path
args: ""

Many server configurations are allowed. Client beans are auto-created by the framework using the given name, for example igniteServerBean01.

#[Autowired('igniteServerBean01')]
private IgniteCacheTemplate $ignite;

This requires the memcached or memcache PHP extension.

memcached:
- name: memcachedServerBean01
serverBinary: /usr/bin/memcached
host: 127.0.0.1
port: 11211
udpPort: 0
unixSocket:
pidfile: "/var/run/memcached_1.pid"
args: "-u memcached "

Many server configurations are allowed. Client beans are auto-created by the framework using the given name, for example memcachedServerBean01.

// `memcached` php extension installed
#[Autowired('memcachedServerBean01')]
private MemcachedTemplate $memcached;
// OR
// if `memcache` php extension installed
#[Autowired('memcacheBean02')]
private MemcacheTemplate $memcache;

Hazelcast needs the memcached PHP extension as a client:

Terminal window
pecl install memcached

Hazelcast configuration:

hazelcast:
- name: hazelcastBean01
serverBinary: etc/hazelcast-4.2.1/bin/start.sh
confFile: /etc/hazelcast/config/hazelcast.xml
bootUpTimeMs: 300
args: ""

Many server configurations are allowed. Client beans are auto-created by the framework using the given name, for example hazelcastBean01.

#[Autowired('hazelcastBean01')]
private MemcachedTemplate $hazelcast;
<hazelcast>
...
<network>
<memcache-protocol enabled="true"/>
</network>
...
</hazelcast>