Comments (5)
also I just realized to avoid always use async/await when calling the function, you can split up the function to establish async await after it knows it can't get it from the cache... I can write the code for this in about an hour
from template.
Refactored:
It now is either going to get it straight from the cache, or if it can't, then rely on async/await to keep efficiency up.
export const findGuild = (guildId: string) => {
const guild = cache.guilds.get(guildId)
if(guild) return guild; //Return the guild if its in the cache
const getStructuredGuild = async () => {
const guildStructure = await getGuild(guildId, true) //Get the guild structure
const shardID = (BigInt(guildStructure.id) >> 22n) % BigInt(botGatewayData.shards)
const struct = await structures.createGuild(guildStructure as CreateGuildPayload, Number(shardID)); //If not create the structure and set it in the cache
cache.guilds.set(struct.id, struct);
return struct; //return it
};
return getStructuredGuild();
};
from template.
For me this is more a utility function which you don't need unless you do advanced caching/sweeping.
from template.
I'm not sure when you would need this. In this template all guilds are cached always. There is no such advanced sweeping in there which could cause it to be uncached.
from template.
@itohatweb I would consider implementing gamers dispatchRequirements here and then perhaps this could be useful
from template.
Related Issues (20)
- Module '"./deps"' has no exported member X deno-ts(2305) HOT 2
- Hot reload HOT 3
- Change Command Execution and Error Handling HOT 4
- Lavadeno Helper voice functionality
- Import Maps HOT 2
- dispatchRequirements HOT 1
- Switch to deno.land v11
- Error on startup after bot prepares slash commands HOT 3
- error: Uncaught (in promise) TypeError: Cannot read property 'entries' of undefined HOT 1
- Delete scripts.yml
- Remove deps.ts HOT 1
- Configs file should use .env file HOT 2
- Remove mod.ts file HOT 1
- Remove cache.ts file
- clarify embed character limit HOT 1
- Still slow as hell HOT 8
- Import error HOT 4
- README: Picture of Command Logs
- Import maps
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from template.