-
Notifications
You must be signed in to change notification settings - Fork 0
Storage Documentation
This document provides an overview and usage examples for the various storage modules available in this library.
The storage-mongo module provides a simple way to interact with a MongoDB database.
// Initialize the MongoDB connection
Mongo mongo = new Mongo("mongodb://localhost:27017", "mydatabase");
mongo.init();
mongo.start();
// Get a collection
MongoCollection<MyObject> collection = mongo.getCollection(MyObject.class);
// ... perform operations on the collection
// Close the connection
mongo.end();The storage-redis module provides a simple way to interact with a Redis server.
// Initialize the Redis connection
Redis redis = new Redis("localhost", 6379);
redis.init();
// Get the Jedis instance
Jedis jedis = redis.getJedis();
// ... perform operations with Jedis
// Close the connection
redis.end();The storage-postgres module provides a simple way to interact with a PostgreSQL database.
// Initialize the PostgreSQL connection
Postgres postgres = new Postgres("localhost", 5432, "mydatabase", "user", "password", true);
postgres.init();
// Get a connection
Connection connection = postgres.getConnection();
// ... perform operations with the connection
// Close the connection
postgres.end();The storage-mysql module provides a simple way to interact with a MySQL database.
// Initialize the MySQL connection
MySQL mysql = new MySQL("localhost", 3306, "mydatabase", "user", "password", true);
mysql.init();
// Get a connection
Connection connection = mysql.getConnection();
// ... perform operations with the connection
// Close the connection
mysql.end();The storage-mariadb module provides a simple way to interact with a MariaDB database.
// Initialize the MariaDB connection
MariaDB mariadb = new MariaDB("localhost", 3306, "mydatabase", "user", "password", true);
mariadb.init();
// Get a connection
Connection connection = mariadb.getConnection();
// ... perform operations with the connection
// Close the connection
mariadb.end();The storage-sqlite module provides a simple way to interact with a SQLite database.
// Initialize the SQLite connection
SQLite sqlite = new SQLite("mydatabase.db");
sqlite.init();
// Get a connection
Connection connection = sqlite.getConnection();
// ... perform operations with the connection
// Close the connection
sqlite.end();The storage-yml module provides a simple way to interact with YAML files.
// Initialize the YAML handler
Yml yml = new Yml("config.yml");
yml.load();
// Get the data
Map<String, Object> data = yml.getData();
// ... perform operations with the data
// Save the data
yml.save();The storage-json module provides a simple way to interact with JSON files.
// Initialize the JSON handler
Json<MyObject> json = new Json<>("data.json", MyObject.class);
json.load();
// Get the data
MyObject data = json.getData();
// ... perform operations with the data
// Save the data
json.save();© 2025 CatMC Network