cluster1.lua 729 B

123456789101112131415161718192021222324252627
  1. local skynet = require "skynet"
  2. local cluster = require "skynet.cluster"
  3. local snax = require "skynet.snax"
  4. skynet.start(function()
  5. cluster.reload {
  6. db = "127.0.0.1:2528",
  7. db2 = "127.0.0.1:2529",
  8. }
  9. local sdb = skynet.newservice("simpledb")
  10. -- register name "sdb" for simpledb, you can use cluster.query() later.
  11. -- See cluster2.lua
  12. cluster.register("sdb", sdb)
  13. cluster.unregister("sdb")
  14. cluster.register("sdb", sdb)
  15. print(skynet.call(sdb, "lua", "SET", "a", "foobar"))
  16. print(skynet.call(sdb, "lua", "SET", "b", "foobar2"))
  17. print(skynet.call(sdb, "lua", "GET", "a"))
  18. print(skynet.call(sdb, "lua", "GET", "b"))
  19. cluster.open "db"
  20. cluster.open "db2"
  21. -- unique snax service
  22. snax.uniqueservice "pingserver"
  23. end)