| @@ 124-147 (lines=24) @@ | ||
| 121 | * @param int $id |
|
| 122 | * @return null|PropertyGroup |
|
| 123 | */ |
|
| 124 | public static function findById($id) |
|
| 125 | { |
|
| 126 | if (!isset(static::$identity_map[$id])) { |
|
| 127 | $cacheKey = "PropertyGroup:$id"; |
|
| 128 | if (false === $group = Yii::$app->cache->get($cacheKey)) { |
|
| 129 | if (null !== $group = static::findOne($id)) { |
|
| 130 | Yii::$app->cache->set( |
|
| 131 | $cacheKey, |
|
| 132 | $group, |
|
| 133 | 0, |
|
| 134 | new TagDependency( |
|
| 135 | [ |
|
| 136 | 'tags' => [ |
|
| 137 | ActiveRecordHelper::getObjectTag(static::className(), $id), |
|
| 138 | ], |
|
| 139 | ] |
|
| 140 | ) |
|
| 141 | ); |
|
| 142 | } |
|
| 143 | } |
|
| 144 | static::$identity_map[$id] = $group; |
|
| 145 | } |
|
| 146 | return static::$identity_map[$id]; |
|
| 147 | } |
|
| 148 | ||
| 149 | /** |
|
| 150 | * Relation to properties |
|
| @@ 65-89 (lines=25) @@ | ||
| 62 | * @param string $id |
|
| 63 | * @return SliderHandler|null |
|
| 64 | */ |
|
| 65 | public static function findBySliderId($id) |
|
| 66 | { |
|
| 67 | if (!isset(SliderHandler::$identity_map[$id])) { |
|
| 68 | $cacheKey = SliderHandler::tableName().":$id"; |
|
| 69 | if (false === $model = Yii::$app->cache->get($cacheKey)) { |
|
| 70 | $model = SliderHandler::findById($id); |
|
| 71 | ||
| 72 | if (null !== $model) { |
|
| 73 | Yii::$app->cache->set( |
|
| 74 | $cacheKey, |
|
| 75 | $model, |
|
| 76 | 86400, |
|
| 77 | new \yii\caching\TagDependency([ |
|
| 78 | 'tags' => [ |
|
| 79 | ActiveRecordHelper::getObjectTag($model, $model->id) |
|
| 80 | ] |
|
| 81 | ]) |
|
| 82 | ); |
|
| 83 | } |
|
| 84 | } |
|
| 85 | static::$identity_map[$id] = $model; |
|
| 86 | } |
|
| 87 | ||
| 88 | return static::$identity_map[$id]; |
|
| 89 | } |
|
| 90 | ||
| 91 | } |
|
| 92 | ||
| @@ 206-228 (lines=23) @@ | ||
| 203 | * @param int $id |
|
| 204 | * @return null|Property |
|
| 205 | */ |
|
| 206 | public static function findById($id) |
|
| 207 | { |
|
| 208 | if (!isset(static::$identity_map[$id])) { |
|
| 209 | $cacheKey = "Property:$id"; |
|
| 210 | if (false === $prop = Yii::$app->cache->get($cacheKey)) { |
|
| 211 | if (null === $prop = static::findOne($id)) { |
|
| 212 | return null; |
|
| 213 | } |
|
| 214 | Yii::$app->cache->set( |
|
| 215 | $cacheKey, |
|
| 216 | $prop, |
|
| 217 | 0, |
|
| 218 | new TagDependency([ |
|
| 219 | 'tags' => [ |
|
| 220 | ActiveRecordHelper::getObjectTag($prop, $id) |
|
| 221 | ], |
|
| 222 | ]) |
|
| 223 | ); |
|
| 224 | } |
|
| 225 | static::$identity_map[$id] = $prop; |
|
| 226 | } |
|
| 227 | return static::$identity_map[$id]; |
|
| 228 | } |
|
| 229 | ||
| 230 | /** |
|
| 231 | * @param $group_id |
|