@soketi/brain
is an abstraction package that handles the caching of data in memory.
import { LocalBrain } from '@soketi/brain';
const brain = new LocalBrain();
await brain.set('key', 'value');
await brain.get('key');
We are planning to support multiple types of brains.
-
LocalBrain
- stores data in memory, in the same process; it's not shared between processes -
RedisBrain
- stores data in Redis -
MemcachedBrain
- stores data in Memcached -
MongoBrain
- stores data in MongoDB -
SqlBrain
- stores data in a SQL database, using Knex
You can create your own brain by implementing the Brain
interface:
import { Brain } from '@soketi/brain';
class MyBrain implements Brain {
// ...
}
const brain = new MyBrain();
This library was generated with Nx.
Run nx build brain
to build the library.
Run nx test brain
to execute the unit tests via Vitest.