code: def __init__(
      self, filename: str, tree_conf: TreeConf, cache_size: int = 512
  ):
      self._filename = filename
      self._tree_conf = tree_conf
      self._lock = rwlock.RWLock()
  
      if cache_size == 0:
          self._cache = FakeCache()
      else:
          self._cache = cachetools.LRUCache(maxsize=cache_size)
  
      self._fd, self._dir_fd = open_file_in_dir(filename)
  
      self._wal = WAL(filename, tree_conf.page_size)
      if self._wal.needs_recovery:
          self.perform_checkpoint(reopen_wal=True)
  
      # Get the next available page
      self._fd.seek(0, io.SEEK_END)
      last_byte = self._fd.tell()
      self.last_page = int(last_byte / self._tree_conf.page_size)
      self._freelist_start_page = 0
  
      # Todo: Remove this, it should only be in Tree
      self._root_node_page = 0
  
imports: import enum
  import io
  from logging import getLogger
  import os
  import platform
  from typing import Union, Tuple, Optional
  import cachetools
  import rwlock
  from .node import Node, FreelistNode
  from .const import ENDIAN, PAGE_REFERENCE_BYTES, OTHERS_BYTES, TreeConf, FRAME_TYPE_BYTES
label_desc: Use image node_id 1 to create a new FileMemory object  with example: obj = FileMemory(filename, tree_conf, cache_size)