JSFiddle - React, Tailwind, and code Playground

by endeepak

HTML

<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/src/simufast.css">
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/main.js"></script>

<script>
    simufast.run((player) => {
        const moduloHash = new simufast.routing.ModuloHash(player);
        const simulation = new simufast.cache.MultiNodeCacheSimulation(moduloHash, {
            nodes: ["S0", "S1", "S2"]
        });
        const keys = simufast.utils.randStringArray(100);
        const commands = [];
        for (let i = 1; i <= 300; i++) {
            const key = simufast.utils.getRandomValueFromArray(keys);
            commands.push(() => simulation.getOrFetch(key, () => `${key}'s value from data source`));
        }
        player.experiment({
            name: 'Modulo Hashing: Static nodes',
            drawable: simulation,
            commands: commands
        });
    }, {
        statsExpanded: true
    });
</script>