Friend spotlight!
Whimsical Animations course
Friend spotlight!
NEW Whimsical Animations course
Friend spotlight! NEW Whimsical Animations course
huge discount only this week
Friend spotlight! Want to make your project stand out? NEW Whimsical Animations course huge discount only this week
Flyweight

Flyweight in PHP

Flyweight is a structural design pattern that allows programs to support vast quantities of objects by keeping their memory consumption low.

The pattern achieves it by sharing parts of object state between multiple objects. In other words, the Flyweight saves RAM by caching the same data used by different objects.

Complexity:

Popularity:

Usage examples: The Flyweight pattern is especially rarely used in PHP applications due to the very nature of the language. A PHP script typically works with a part of the application’s data and never loads all of it into the memory at the same time.

Identification: Flyweight can be recognized by a creation method that returns cached objects instead of creating new.

Flyweight in Other Languages

Flyweight in C# Flyweight in C++ Flyweight in Go Flyweight in Java Flyweight in Python Flyweight in Ruby Flyweight in Rust Flyweight in Swift Flyweight in TypeScript