suvera/winter-memdb

Winter Memdb module supports many In memory databases, such as Apache Ignite, Redis, Memcached etc..

dev-master 2021-07-31 05:31 UTC

This package is auto-updated.

Last update: 2024-04-29 04:53:38 UTC


README

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

Setup

  1. 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)

memdb-config.yml

# 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

1. Redis

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;

2. Apache Ignite

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;

3. Memcached

  • This requires memcached or memcache 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;

4. Hazelcast

  • 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>