Winter Memory DB (memdb) is a module that provides in-memory database engines integrated into winter-boot framework.
Following databases maybe integrated, Auto-started on application startup and stopped upon application stop.
- Redis
- Apache Ignite
- Hazelcast
- Memcached
- RocksDB
- H2
- This requires
swoole
php extension
composer require suvera/winter-memdb
To enable Memdb module in applications, append following code to application.yml
modules:
- module: dev\winterframework\memdb\MemdbModule
enabled: true
configFile: memdb-config.yml
configFile is a file path (relative to config dir or absolute path)
# 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 configuration
redis:
- name: redisServerBean01
serverBinary: /usr/local/bin/redis-server
confFile: redis_1.conf # relative or absolute path
args: ""
- Many number of server configurations allowed.
- Client Beans will be auto-created by framework by given name. ex: "redisServerBean01"
#[Autowired('redisServerBean01')]
private PhpRedisTemplate $redis;
Apache Ignite configuration
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 number of server configurations allowed.
- Client Beans will be auto-created by framework by given name. ex: "igniteServerBean01"
#[Autowired('igniteServerBean01')]
private IgniteCacheTemplate $ignite;
- This requires
memcached
ormemcache
php extension
Memcached configuration.
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 number of server configurations allowed.
- Client Beans will be auto-created by framework by given name. ex: "memcachedServerBean01"
// `memcached` php extension installed
#[Autowired('memcachedServerBean01')]
private MemcachedTemplate $memcached;
// OR
// if `memcache` php extension installed
#[Autowired('memcacheBean02')]
private MemcacheTemplate $memcache;
- Hazelcast needs
memcached
php extension as a client
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 number of server configurations allowed.
- Client Beans will be auto-created by framework by given name. ex: "hazelcastBean01"
#[Autowired('hazelcastBean01)]
private MemcachedTemplate $hazelcast;
Note: Hazelcast configuration need memcache enabled. see it here https://docs.hazelcast.com/imdg/4.2/clients/memcache.html
<hazelcast>
...
<network>
<memcache-protocol enabled="true"/>
</network>
...
</hazelcast>