Can ModuleScripts link cashe to the requiree?

As the title says, I am wondering if a ModuleScript is capable of saving cashe in variables that can be read when the function is called again. I know that making a bunch of IntValues in a reserved folder can act as cashe, but I am certain that there is another way for a ModuleScript to save cashe.

Now, you might ask: ‘Why not save the cashe on a script after using the function in the ModuleScript’, I am making a module resource and not a personal-only one.

Attaching a script to save the Cashe ‘might’ work, but I do not want to confuse myself to using a lower-effiecent cashe-ing method when there is a far better one.

NOTE:
By ‘saving’ I do not mean data-store saving, I need to save an array somehow to the ModuleScript so that the same script that requires it has a personal array stored about the data it used.

And I am not trying to share data between 2 scripts or cross the client-server boundry, I just need the Data to be able to be referanced from one script that requires it, and for each script-that-requires to also have a personal cashe that can be linked to them.

2 Likes

After doing some experiments, I noticed that just arrays can do what I wanted. Is that the most effiecency it can get or is there a more secure, more reliable and faster method?

1 Like
local ModuleScript = {}

local cache = {}
ModuleScript["Cache"] = cache

return ModuleScript
2 Likes

Not entirely what I meant, as the Cashe does not need to be returned but instead needs to be used for the functions in the module script, but the concept should work then.

1 Like

Are you referring to a cache which would log the module’s variables/functions when indexed via the requiring script?

2 Likes

No.

Just Cashe that the functions in the module script read and write for managing certain tasks.

local module = {}
local cache  = {}

function module:aFunction()
   table.insert(cache, "foo")
end

return module

Thanks! I already got an answer but that would also work!

No problem, you just didnt mark an answer so I didnt think you had one.

Turns out what you wanted was what I described.

It seems to me that you meant the table where the functions are that would be returned to the requester, but I just needed the cashe to be able to help the functions communicate with each other and not being sent to the requester.

Eithier way, this post has a solution now.

I think what I initially described may have confused you. I was referring to a cache that would log which of the module’s functions/variables had been accessed.

Does it matter? OP already received his solution so there is no need for an argument on who solved it.

Does what matter? What argument are you referring to?

It would help if the thread’s poster were more precise in their posts (and made an effort to omit spelling/grammatical errors).

This is just what I use the cashe for, others may use it differently:
image

ReserveCashe is for temp storing data to be processed later.
LogCashe is just for Logs
CommandDataCashe cashes the Command Data to be referanced later.
ConnectionCashe just stores a lot of connections.

Spoiler: I am making a chat-command module, should be out today or tommorow.

The argument that you started and are now ignoring :joy:

Why does it matter who solved it? What matters is that OP received the solution to his question and we should leave it at that.

And now you’re insulting OP’s grammar… that’s hilarious.

1 Like

I’m not claiming that I solved the thread nor that I should be given the solution mark. You must be confused/ill-informed.

I’m merely stating that the thread’s poster should be more specific (less ambiguous) in their posts.

What they were asking for is different to what they wanted, as evident here:

Not entirely what I meant, as the Cashe does not need to be returned

@deluc_t and @Forummer, no need to argue about who answered the question first or whatever you are argueing about, I appreciate that you both helped me and that I got a solution. You both contributed well and I thank you both and others who helped me with the problem!

1 Like