Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Warning Expired! Params, when i using 0 in defaultExpires and expires #271

Open
mr2726 opened this issue Mar 29, 2024 · 3 comments
Open

Comments

@mr2726
Copy link

mr2726 commented Mar 29, 2024

Hello everyone
see my code

import React, { useState, useEffect } from 'react';
import { View } from 'react-native';
import Storage from 'react-native-storage';
import AsyncStorage from '@react-native-async-storage/async-storage';

const storage = new Storage({
  size: 1000,
  storageBackend: AsyncStorage, 
  defaultExpires:  0, // <- talking about this line
  enableCache: true,
});
storage.save({
  key: 'first',
  data: {
    from: 'some other site',
    userid: 'some userid',
    token: 'some token'
  },
  expires: 0 // <- talking about this line
});

const _loadData = () => {
  storage.load({
    key: 'first',

    autoSync: true,
    syncInBackground: true,
  })
  .then(ret => {
    console.log(ret);
  })
}

function App(): React.JSX.Element {
  useEfect(() => {
    _loadData()
  }, [])
  return (
    <View></View>
  );
}

export default App;

so when i'm running this code i see the following warn.

 WARN  Expired! Params: {"ret":{"rawData":{"from":"some other site","userid":"some userid","token":"some token"},"expires":1711700444828},"key":"first","autoSync":true,"syncInBackground":true}

when i am chang the 0 to default params like 1000 * 3600 * 24, it works fine.

@sunnylqm
Copy link
Owner

0 means expire immediately. what do you expect?

@Primilink
Copy link

Zero is not the same as null, if you want it to never expire use null instead of 0

@albornozgusti
Copy link

hi, be careful with the values that you are using. as they said, Zero is not the same as null. let me show with a screenshot with RunJs:
image

line 2 and 3 are basically the same, but i want you to know that "null" is not the same as "empty" if you want to see from other perspective.
Anyway, i suggest you to read the docs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants