This package provides a lock mechanism that can be used if the library runs in multi-process or cluster-mode. The locks are needed to avoid race conditions when installing libraries.
import ioredis from'ioredis-mock';import { H5PEditor, H5PPlayer } from'@lumieducation/h5p-server';import RedisLockProvider from'@lumieducation/h5p-redis-lock';// Create a regular ioredis connectionconstredis=newioredis(redisPort, redisHost, { db: redisDb });// Create the lock providerconstlockProvider=newRedisLockProvider(redis);// Pass it to the editor and player objectconsth5pEditor=newH5PEditor( /*other parameters*/, options: { lockProvider } );consth5pPlayer=newH5PPlayer( /*other parameters*/, options: { lockProvider } );
It is important to make sure that all instances of H5PEditor use a redis lock provider that points to the same database. Otherwise race conditions can happen.