code: def put(self, data, filename, binary=True) -> str:
      if not self.cache_dir:
          raise RuntimeError("Could not create or locate cache dir")
      binary = isinstance(data, bytes)
      if not binary:
          data = str(data)
      assert self.lock_path is not None
      filepath = self._make_path(filename)
      # Random ID to avoid any collisions
      rnd_id = random.randint(0, 1000000)
      # we use the PID in case a bunch of these around so we can see what PID made it
      pid = os.getpid()
      # use tempfile to be robust against program interruptions
      temp_path = f"{filepath}.tmp.pid_{pid}_{rnd_id}"
      mode = "wb" if binary else "w"
      with open(temp_path, mode) as f:
          f.write(data)
      # Replace is guaranteed to be atomic on POSIX systems if it succeeds
      # so filepath cannot see a partial write
      os.replace(temp_path, filepath)
      return filepath
  
imports: import json
  import os
  import random
  from abc import ABC, abstractmethod
  from pathlib import Path
  from typing import Dict, Optional
  import hashlib
label_desc: Use image node_id 7 for calling the FileCacheManager obj's underlying member method code with example usage: obj.put(data, filename, binary) and returns: filepath