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:
composer require suvera/winter-memdbEnable the module in application.yml:
modules: - module: dev\winterframework\memdb\MemdbModule enabled: true configFile: memdb-config.ymlconfigFile is a file path (relative to the config directory or an absolute path).
memdb-config.yml
Section titled “memdb-config.yml”The configuration file can define any number of engines, each with its own top-level key:
# Redisredis:# Redis Configuration here, see below section
# Apache Igniteignite:# Apache Ignite Configuration here
# Memcachedmemcached:# Memcached Configuration here
# Hazelcasthazelcast:# Hazelcast Configuration here1. Redis
Section titled “1. Redis”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;2. Apache Ignite
Section titled “2. Apache Ignite”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;3. Memcached
Section titled “3. Memcached”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;4. Hazelcast
Section titled “4. Hazelcast”Hazelcast needs the memcached PHP extension as a client:
pecl install memcachedHazelcast 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>