Skip to content

Commit d3f79ac

Browse files
authored
Added uz language (#243)
(O'zbek tili qo'shildi)
1 parent 0026995 commit d3f79ac

File tree

6 files changed

+259
-0
lines changed

6 files changed

+259
-0
lines changed

docs/guide-uz/README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
Yii 2 Kesh, Sessiya va ActiveRecord uchun Redis
2+
===============================================
3+
4+
Bu kengaytma key-value(kalit-qiymat) ma'lumotlarni Yii2 [Redis](http://redis.io/) saqlash uchun yordam beradi.
5+
6+
Ishni boshlash
7+
---------------
8+
9+
* [O'rnatish](installation.md)
10+
11+
Foydalanish
12+
-----
13+
14+
* [ActiveRecord orqali foydalanish](usage-ar.md)
15+
* [To'g'ridan-to'g'ri buyruqlar orqali foydalanish](usage-commands.md)
16+
17+
Qo'shimcha
18+
-----------------
19+
20+
* [Kesh uchun foydalanish](topics-cache.md)
21+
* [Sessiya uchun foydalanish](topics-session.md)

docs/guide-uz/installation.md

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
O'rnatish
2+
============
3+
4+
## Talablar
5+
6+
Barcha komponentlar to'g'ri ishlashi uchun kamida [Redis](http://redis.io/) 2.6.12 versiyasi talab qilinadi.
7+
8+
## Composer orqali o'rnatish
9+
10+
[Composer](http://getcomposer.org/download/) orqali o'rnatish eng yaxshi usuldir.
11+
12+
Quyidagi buyruq orqali o'rnatish mumkin:
13+
14+
```
15+
php composer.phar require --prefer-dist yiisoft/yii2-redis
16+
```
17+
18+
yoki `composer.json` fayliga `require` bo'limiga quyidagilarni qo'shish orqali
19+
20+
```json
21+
"yiisoft/yii2-redis": "~2.0.0"
22+
```
23+
24+
o'rnatish mumkin.
25+
26+
## Sozlash
27+
28+
Kengaytmadan foydalanish uchun Yii2 sozlamalaridan `[[yii\redis\Connection|Connection]]` sinfini quyidagicha sozlashingiz kerak
29+
30+
```php
31+
return [
32+
//....
33+
'components' => [
34+
'redis' => [
35+
'class' => 'yii\redis\Connection',
36+
'hostname' => 'localhost',
37+
'port' => 6379,
38+
'database' => 0,
39+
],
40+
]
41+
];
42+
```
43+
44+
Quyidagi kodlar orqali redis'ga ma'lumot kiritish va o'qishning eng oddiy holatini ko'rish mumkin
45+
46+
```php
47+
Yii::$app->redis->set('mykey', 'some value');
48+
echo Yii::$app->redis->get('mykey');
49+
```
50+
51+
Boshqa metodlarni ko'rish uchun `[[yii\redis\Connection]]` sinfiga qarang.

docs/guide-uz/topics-cache.md

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
Kesh uchun foydalanish
2+
=========================
3+
4+
Redis'dan keshda foydalanish uchun [O'rnatish](installation.md) bo'limida tavsiflanganidek sozlashdan tashqari,
5+
[[yii\redis\Cache]] sinfi ham sozlashingiz kerak:
6+
7+
```php
8+
return [
9+
//....
10+
'components' => [
11+
// ...
12+
'cache' => [
13+
'class' => 'yii\redis\Cache',
14+
],
15+
]
16+
];
17+
```
18+
19+
Agar siz faqat redis keshidan foydalansangiz (ya'ni, ActiveRecord yoki Sessiya uchun foydalanmasangiz),
20+
kesh komponentini o'zida ulanish sozlamalarini ham kiritishingiz mumkin
21+
(bu holda [O'rnatish](installation.md) bo'limidagi sozlashni bajarish shart emas):
22+
23+
```php
24+
return [
25+
//....
26+
'components' => [
27+
// ...
28+
'cache' => [
29+
'class' => 'yii\redis\Cache',
30+
'redis' => [
31+
'hostname' => 'localhost',
32+
'port' => 6379,
33+
'database' => 0,
34+
],
35+
],
36+
]
37+
];
38+
```
39+
40+
Kesh `[[yii\caching\CacheInterface]]` interfeysidagi barcha metodlardan foydalanish imkonini beradi.
41+
Interfeysga kiritilmagan Redis maxsus metodlaridan foydalanmoqchi bo'lsangiz, [[yii\redis\Cache::$redis]] orqali foydalanishingiz mumkin,
42+
bu [[yii\redis\Connection]] holatidagi namuna:
43+
44+
```php
45+
Yii::$app->cache->redis->hset('mykey', 'somefield', 'somevalue');
46+
Yii::$app->cache->redis->hget('mykey', 'somefield');
47+
...
48+
```
49+
50+
Boshqa metodlarni ko'rish uchun `[[yii\redis\Cache]]` sinfiga qarang.

docs/guide-uz/topics-session.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
Sessiya uchun foydalanish
2+
===========================
3+
4+
Redis'dan sessiyada foydalanish uchun [O'rnatish](installation.md) bo'limida tavsiflanganidek sozlashdan tashqari,
5+
[[yii\redis\Session]] sinfi ham sozlashingiz kerak:
6+
7+
```php
8+
return [
9+
//....
10+
'components' => [
11+
// ...
12+
'session' => [
13+
'class' => 'yii\redis\Session',
14+
],
15+
]
16+
];
17+
```
18+
19+
Agar siz faqat redis sessiyaidan foydalansangiz (ya'ni, ActiveRecord yoki Kesh uchun foydalanmasangiz),
20+
sessiya komponentini o'zida ulanish sozlamalarini ham kiritishingiz mumkin
21+
(bu holda [O'rnatish](installation.md) bo'limidagi sozlashni bajarish shart emas):
22+
23+
```php
24+
return [
25+
//....
26+
'components' => [
27+
// ...
28+
'session' => [
29+
'class' => 'yii\redis\Session',
30+
'redis' => [
31+
'hostname' => 'localhost',
32+
'port' => 6379,
33+
'database' => 0,
34+
],
35+
],
36+
]
37+
];
38+
```
39+
40+
Boshqa metodlarni ko'rish uchun `[[yii\redis\Session]]` sinfiga qarang.

docs/guide-uz/usage-ar.md

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
ActiveRecord orqali foydalanish
2+
======================
3+
4+
Avvalo Yii2'da ActiveRecord'dan qanday foydalanish haqida umumiy ma'lumot olish uchun [qo'llanma](https://github.com/yiisoft/yii2/blob/master/docs/guide/db-active-record.md) ga qarang.
5+
6+
Redis'dan ActiveRecord orqali foydalanish uchun sizning sinfingiz [[yii\redis\ActiveRecord]] vorisi bo'lish va
7+
sinfingizda kamida `attributes()` metodi bo'lishi kerak.
8+
9+
10+
11+
PrimaryKey'ni `[[yii\redis\ActiveRecord::primaryKey()]]` orqali tanitish mumkin, agar berilmagan bo'lsa, `id` PrimaryKey sifatida tanitiladi.
12+
PrimaryKey'ni ko'rsatmagan bo'lsangiz, PrimaryKey sifatida `id` olinganligini tekshiring.
13+
14+
Quyida `Customer` nomli namunaviy model keltirilgan:
15+
16+
```php
17+
class Customer extends \yii\redis\ActiveRecord
18+
{
19+
/**
20+
* @return array the list of attributes for this record
21+
*/
22+
public function attributes()
23+
{
24+
return ['id', 'name', 'address', 'registration_date'];
25+
}
26+
27+
/**
28+
* @return ActiveQuery defines a relation to the Order record (can be in other database, e.g. elasticsearch or sql)
29+
*/
30+
public function getOrders()
31+
{
32+
return $this->hasMany(Order::className(), ['customer_id' => 'id']);
33+
}
34+
35+
public static function find()
36+
{
37+
return new CustomerQuery(get_called_class());
38+
}
39+
}
40+
41+
class CustomerQuery extends \yii\redis\ActiveQuery
42+
{
43+
/**
44+
* Defines a scope that modifies the `$query` to return only active(status = 1) customers
45+
*/
46+
public function active()
47+
{
48+
return $this->andWhere(['status' => 1]);
49+
}
50+
}
51+
```
52+
53+
Общее использование redis ActiveRecord очень похоже на БД ActiveRecord как описано в [руководстве](https://github.com/yiisoft/yii2/blob/master/docs/guide/db-active-record.md).
54+
Он поддерживает тот же интерфейс и функции, за исключением следующих ограничений:
55+
56+
Redis'dan ActiveRecord'da foydalanish, ma'lumotlar bazasi bilan ishlashga juda o'xshaydi.
57+
Faqat u quyidagi cheklovlardan tashqari bir xil interfeys va xususiyatlarni qo'llab-quvvatlaydi:
58+
59+
- Redis SQL'ni qo'llab-quvvatlamagani uchun quidagi metodlardan foydalanib bo'lmaydi
60+
`where()`, `limit()`, `offset()`, `orderBy()` va `indexBy()`.
61+
- `via` - jadval via orqali aniqlab (bog'lanib) bo'lmaydi, chunki redisda jadvallar mavjud emas. Siz bog'lanishlarni boshqa ma'lumotlar orqali belgilashingiz mumkin.
62+
63+
Redis ActiveRecords dan oddiy ActiveRecord sinflariga va aksincha bog'lanishlarni aniqlashingiz mumkin.
64+
65+
Masalan:
66+
67+
```php
68+
$customer = new Customer();
69+
$customer->attributes = ['name' => 'test'];
70+
$customer->save();
71+
echo $customer->id; // id will automatically be incremented if not set explicitly
72+
73+
$customer = Customer::find()->where(['name' => 'test'])->one(); // find by query
74+
$customer = Customer::find()->active()->all(); // find all by query (using the `active` scope)
75+
```

docs/guide-uz/usage-commands.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
To'g'ridan-to'g'ri buyruqlar orqali foydalanish
2+
=======================
3+
4+
Redis'da to'g'ridan-to'g'ri ulanishdan foydalanishda, juda ko'p buyruqlar mavjud.
5+
Ilovani [O'rnatish](installation.md)da ko'rsatilganidek sozlaganingizdan so'ng, quyidagi kabi ulanishga erishish mumkin
6+
```php
7+
$redis = Yii::$app->redis;
8+
```
9+
10+
Sozlab bo'lganingizdan so'ng, to'g'ridan to'g'ri buyruq berish uchun executeCommand metodi asosiy hisoblanadi.
11+
12+
```php
13+
$result = $redis->executeCommand('hmset', ['test_collection', 'key1', 'val1', 'key2', 'val2']);
14+
```
15+
16+
Qo'llab quvvatlanadigan barcha buyruqlarni quyidagicha bajarish ham mumkin:
17+
18+
```php
19+
$result = $redis->hmset('test_collection', 'key1', 'val1', 'key2', 'val2');
20+
```
21+
22+
Redis'ning mavjud buyruqlari haqida <http://redis.io/commands> sahifasida o'rganib chiqishingiz mumkin.

0 commit comments

Comments
 (0)