Introducing: GreenwichDB / Greenwich
Hello, human on earth! May I introduce you to GreenwichDB!
Found a bug? Contact us in the Discord Server.
What is Greenwich
Greenwich is a Studios on ROBLOX which makes games. The team currently is provided with 2 people, (Noobie and Salvage.) We’re very excited to make games and we also decided to make a Datastore Wrapper. Read more down below!
What is GreenwichDB?
General Information [1]
GreenwichDB is an Open Source Code Project. GreenwichDB is a Wrapper for ROBLOX Datastores. This wrapper is insanely fast, and your data is loaded in once you join your game.
Contributors:
Salvage_Dev: @hghguy
NoobieYT: @NoobiDerpieDev
Concept [2]
The concept of GreenwichDB is to provide one Datastore, and just one, in order to completely remove complications. It’s faster and lighter on the server, and efficient.
Installation [3]
Of course! We’ll guide you through every step, in order to succesfully install GreenwichDB into your ROBLOX game.
- Insert a ModuleScript into ServerStorage.
- Rename the ModuleScript to “Greenwich” (without the " " marks.)
- Paste the following Code into the ModuleScript
Usage [4]
Now that you have GreenwichDB installed, we can guide through the usage of GreenwichDB. Sit tight!
1. Insert a Script into ServerScriptService.
2. Open the Script we just created, and paste in the following code to require GreenwichDB into your game.
local Storage = game:GetService("ServerStorage")
local Greenwich = require(Storage:WaitForChild("Greenwich"))
Let’s break this down. As you can see, we are getting ServerStorage and defining that as a variable, Storage
. We then require
the script Greenwich
which is the ModuleScript we created earlier.
3. Creating a Datastore.
The first thing we have to do is “Create a DB”. Since we are actually never creating a Datastore - it happens once when the ModuleScript gets runned. So, what we are doing is we are just passing the custom key, which is the argument in the GetDB
function.
Let’s use this in a real world example.
local Money = Greenwich:GetDB("Money")
In this code, we are going to be creating a new store - not a Datastore, a store, which is considered the first key allowing for us to use only one Datastore ever.
4. Setting some data
Setting data is probably the simplest but also the most complex thing. It has 3
options, allowing you to really customize how you want to save data.
What the arguments are?
-
-
key
- The key that the value should be saved to
-
-
-
value
- The value that should be saved to the key
-
-
-
shouldSave
- The value that decides if the Data should be saved to the DS and the cache or just the cache. It defaults to saving to both. If you use this and set shouldSave tofalse
you will need to use:Save(key)
to update the Datastore with the value that you have in the cache.
-
5. Getting data
Getting data is very easy, it’s a simple :Get(key)
.
Arguments:
-
-
key
- The key to search the *cache and *DS for.
-
6. API Reference
Woot woot, you’ve reached the part where all the functions are described.
DB:Get
→ Get a value from the cache or Datastore
-
key
- The key to search the cache and DS for.
DB:Set
→ Set a value to the cache, Datastore or both.
-
key
- The key to save to -
value
- The value to save to the key -
shouldSave
- The value that decides if the Data should be saved to the DS and the cache or just the cache. It defaults to saving to both. If you use this and set shouldSave tofalse
you will need to use:Save(key)
to update the Datastore with the value that you have in the cache.
DB:Delete
→ Delete something from the cache and Datastore.
-
key
- The key to delete from the cache and Datastore
DB:Has
→ Check if the Datastore or cache contains the key
-
key
- The key to search through the Datastore and cache to see if the key has a value assigned.
DB:Save
→ Save data that was in the cache to the Datastore. Should only be used if somewhere you set shouldSave
to false
in the Set
function.
DB:Fetch
→ Fetching data from the Datastore and adding it to the queue.
-
player
- The player to fetch data from (e.gDB:Fetch(Player.UserId)
)
Greenwich:EndQueue
→ Run all requests defined in the queue. Should be used before server shutdown.
No arguments
If you have any questions, please join our Discord listed below!
7. The caching layer
The way the cache works is the fact that we prioritize getting data from the cache. This means you will do less Datastore requests, and if the value isn’t in the cache, we will add the value to the cache as soon as it is fetched. We do this because it allows us to speed up things massively, and only takes up a little bit of memory usage.
8. The queue system
The queue system ensures that your Datastore is faster (see the technical video listed below for a comparison) and will also ensure you get less errors. This means that you won’t get any Datastore Request queue handler errors, and if you ever do, that’ll be because you called EndQueue
- which should only be called on server shutdown.
9. Conclusion
Greenwich is lightweight, has a simple and stable API and has various speed improvements. Enjoy!
History of GreenwichDB
The idea of GreenwichDB was originally made by @hghguy (Aka. Salvage_Dev), he immediately reached to @NoobiDerpieDev (aka. NoobieYT) and introduced me to the idea of GreenwichDB. We made GreenwichDB from scratch within 2 days, to make it usable & beginner friendly (we succeeded!)
Some Handy Links
Github: Greenwich · GitHub
ROBLOX: Greenwich - Roblox
Technical Video: - YouTube
Usage Video: ROBLOX STUDIO | How to use GreenwichDB [Instant Data Loading!] - YouTube
Discord: Greenwich
Thank you for looking at GreenwichDB!
Powered by Greenwich