Closed phoenixlzx closed 5 years ago
Available at maven-repo-dev and 4.2 releases
Mysql database from DriverManager. Jdbc driver com.mysql.jdbc.Driver
is bundled with spigot by default.
database:
provider: mysql
connection:
autoscan: true
url: jdbc:MySQL://localhost:3306/heh
username: username
password: password
# 'package' and 'jdbc' are optional
package: cat.nyaa.HamsterEcoHelper.utils.database.tables
jdbc: com.mysql.jdbc.Driver
or select table classes manually
database:
provider: mysql
connection:
autoscan: false
url: jdbc:MySQL://localhost:3306/heh
username: root
password: root
tables:
- cat.nyaa.HamsterEcoHelper.utils.database.tables.TempStorageRepo
- cat.nyaa.HamsterEcoHelper.utils.database.tables.MarketItem
- cat.nyaa.HamsterEcoHelper.utils.database.tables.ItemLog
- cat.nyaa.HamsterEcoHelper.utils.database.tables.signshop.SignShop
- cat.nyaa.HamsterEcoHelper.utils.database.tables.signshop.Sign
- cat.nyaa.HamsterEcoHelper.utils.database.tables.signshop.ShopStorageLocation
- cat.nyaa.HamsterEcoHelper.utils.database.tables.signshop.LottoStorageLocation
# 'jdbc' is optional
jdbc: com.mysql.jdbc.Driver
Sqlite database from DriverManager. Always requires org.sqlite.JDBC
which is also came with spigot. Also support autoscan: false
with tables
section.
database:
provider: sqlite
connection:
autoscan: true
file: HamsterEcoHelper.db
# 'package' is optional
package: cat.nyaa.HamsterEcoHelper.utils.database.tables
https://github.com/Librazy/HibernateProvider Based on Hibernate ORM to support various SQL database.
database:
provider: hibernate
connection:
autoscan: true
url: jdbc:MySQL://localhost:3306/heh
username: root
password: root
# 'jdbc' is optional
jdbc: com.mysql.jdbc.Driver
# 'dialect' coming soooon
dialect: org.hibernate.dialect.MySQL57Dialect
Java collection Map. No configuration is available. Not persisted and will be cleared when restart/reload.
database:
provider: map
connection: []
https://github.com/NyaaCat/RedisProvider Based on lettuce, a powerful redis client for Java.
database:
provider: redis
connection:
url: redis://localhost/
# or use 'host' 'port' 'database' and 'database' instead of 'url'
# 'key' and 'value' should match the types where requires it. Default to String
key: java.util.UUID
value: cat.nyaa.nyaautils.lootprotect.LootProtectListener$VanillaStrategy
有一个额外的需求支持:
per-player configuration,在数据库中单独创建一个表,使用 k-v 方式存储。
例如 NyaaUtils 的 lootprotect 设置,key 是 ncppc:nyaautils:lp:<playeruuid>
value 是 reject
类似。
这些配置不需要分插件,也不需要强制持久化,共用一张表或直接用单独的前缀可以省去各单独插件对于这些玩家单独配置的存储。可以看作是 NC 的 kv 扩充。
hmm目前redis的设计是要求每一处使用新开一个redis数据库……还没想好前缀这个要怎么做(
redis 看起来还没 merge 进 NC6 的样子?
独立的,在 RedisProvider 这个 repo
NC 作为中间件提供一个抽象的数据库操作接口,对多种数据库提供支持。
插件在调用时通过读取插件自身的数据库类型和配置建立一个数据库连接实例,使用 NC 的抽象方法对数据库连接实例进行 CRUD 操作。
例如插件的配置中:
provider
需要支持:connection
调用时交由 provider 解析数据库连接信息。host
数据库主机username
和password
数据库连接信息db_name
在不同类型数据库中的作用nyaa_p1:plugin_func2:some_data
[x] SQLite 支持
[x] MySQL 支持
[ ] MongoDB 支持
[x] Redis 支持
[x] 抽象类中间件
[ ] 容错检查和测试例
[ ] 文档
[ ] 数据迁移工具
其他需要注意的?