๐ค Lazy + cache
๐ Protection
๐ผ photo-1
๐ผ photo-2
๐ผ photo-3
โบ Reset
requests:
0
disk loads:
0
client โ proxy โ real image ยท same interface:
display()
๐ค
CLIENT
calls display()
โ
โก
๐ช
PROXY
ImageProxy ยท cache
p1
p2
p3
from cache
โ
๐พ
REAL IMAGE
RealImage ยท 5 MB on disk
๐ผ
loaded 5 MB
๐ Guest
๐ก Admin
โถ Delete photo
โบ Reset
real object calls:
0
client โ proxy โ real object ยท same interface:
deleteImage()
๐ค
CLIENT
role: guest
โ
๐ช
PROXY
checks role first
โ denied
โ
๐
REAL OBJECT
deleteImage()
๐ผ
untouched
Proxy โ a stand-in with the same interface
Click a photo โ the proxy decides whether the disk is touched.
โธ
Click the
same photo twice
โ watch which chip moves.