Comments (7)
Hi @TheRND, thanks for pointing that out!
I think is better remove userId from constructor and move it to method parameters, as you said.
I'll fix it as soon as I can.
from php-mattermost-driver.
Hi @TheRND,
I finally decided to not cache the model, keeping the "userId" parameter in the constructor. In this way no breaking changes were introduced.
Thanks again for pointing this out!
from php-mattermost-driver.
The better way, probably, is to cache model, but implement setter method and explicitly set userId on retrieval in Dirver::getPreferencesModel($userId)?
from php-mattermost-driver.
Oh that could be a good idea, you mean something like this:
/**
* @param $userId
* @return PreferenceModel
*/
public function getPreferenceModel($userId)
{
if (!isset($this->models[PreferenceModel::class][$userId])) {
$this->models[PreferenceModel::class][$userId] = new PreferenceModel($this->container['client'], $userId);
}
return $this->models[PreferenceModel::class][$userId];
}
so every instance of a user id is cached. I wonder, however, if it does not overload the memory where there are many retrieval with different user ids.
from php-mattermost-driver.
Not exactly, I meant something like this:
/**
* @param $userId
* @return PreferenceModel
*/
public function getPreferenceModel($userId)
{
if (!isset($this->models[PreferenceModel::class])) {
$this->models[PreferenceModel::class] = new PreferenceModel($this->container['client']); // Remove userid from constructor and move it into setter
}
return $this->models[PreferenceModel::class]->setUserId($userId); // Transient setter
}
So we've got single instance cached and kept getPreferenceModel($userId) method signature for backward compatibility
from php-mattermost-driver.
Great! I like it, I will implement your solution this weekend.
from php-mattermost-driver.
Done 😊
from php-mattermost-driver.
Related Issues (20)
- Join forces on MattermostAPI client? HOT 3
- Message with File Attached HOT 8
- " Class 'Pimple\Container' not found" HOT 1
- Can not upload file HOT 7
- Can't use search in channel ! HOT 6
- Methods to manage icons HOT 4
- Returns 500 HOT 4
- Laravel 7 support? HOT 2
- Support limit_after and limit_before parameters in request to get posts around oldest unread HOT 3
- With https:// in the beginning 500 error and without nothing happens HOT 5
- Laravel 7 Support HOT 2
- guzzle 7.x support HOT 1
- Missing Endpoints in ReactionModel? HOT 2
- Endpoint for custom user status HOT 1
- Fatal error: Declaration of Illuminate HOT 8
- Guzzle HOT 2
- Decouple from Pimple HOT 5
- Add optional permanent=true to user and channel delete HOT 1
- Api function
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from php-mattermost-driver.