| Server IP : 185.208.173.17 / Your IP : 87.236.161.98 Web Server : Microsoft-IIS/10.0 System : Windows NT SRV8576125506 10.0 build 26100 (Windows Server 2016) AMD64 User : IUSR ( 0) PHP Version : 7.4.13 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : C:/inetpub/wwwroot/parsmega.nuxt/node_modules/memcache-plus/docs/ |
Upload File : |
# Get Multiple
Let's say you want to get 5 keys at once. The following is rather onerous:
```javascript
Promise
.all([
client.get('hydrogen'), client.get('helium'),
client.get('oxygen'), client.get('carbon'), client.get('nitrogen')
])
.then(function(values) {
console.log('Successfully retrieved these 5 keys');
});
```
The above would also fire off 5 separate calls from your client to your Memcached
server.
Thankfully Memcache Plus provides a convenience method called `getMulti()` that
will combine these into a single call:
```javascript
client
.getMulti(['hydrogen', 'helium', 'oxygen', 'carbon', 'nitrogen'])
.then(function(values) {
console.log('Successfully retrieved these 5 keys');
});
```
or with async/await
```javascript
const values = await client.getMulti(['hydrogen', 'helium', 'oxygen', 'carbon', 'nitrogen'])
console.log('Successfully retrieved these 5 keys');
// You can also use destructuring if you'd like to get each of these as their
// own variable
const [hydrogen, lithium, sodium] = await client.get(['hydrogen', 'lithium', 'sodium'])
console.log(`${ hydrogen } and ${ lithium } and ${ sodium }`
```