Skip to content
This repository was archived by the owner on Dec 7, 2019. It is now read-only.
This repository was archived by the owner on Dec 7, 2019. It is now read-only.

RecordPersister's 'Expiration' is not working #372

@gaurav-m

Description

@gaurav-m
StoreBuilder.<BarCode, BufferedSource, List<ListDto>>parsedWithKey()
        .fetcher(barCode -> responseConverter(
            serverRestClient.getListsSingleForStore()))
        .memoryPolicy(getMemoryPolicy())
        .persister(getDataPersister(context))
        .parser(GsonParserFactory.createSourceParser(gson, new TypeToken<List<ListDto>>() {
        }.getType()))
        .open();

private Persister getDataPersister(Context context) {
    try {
      return RecordPersister.create(getFileSystem(context), 1, TimeUnit.MINUTES);
    } catch (IOException e) {
      e.printStackTrace();
    }
    return null;
  }

 private MemoryPolicy getMemoryPolicy() {
    return MemoryPolicy
        .builder()
        .setExpireAfterWrite(1)
        .setExpireAfterTimeUnit(TimeUnit.DAYS)
        .build();
  }

Data is fetched from the disk(not from network) even after the expiation time(here 1 minute).
Note : I am force killing the application and re-launching, so memory data is not used.

I even tried adding

networkBeforeStale()

But no change.
I read everything I could find online around this. So far no progress.

*Fresh data from network is fetched after i do this
Device Settings -> Applictions -> My Application -> Clear Cache

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions