ElijahPaul

Experience

350

0 Best Reply Awards

  • Member Since 2 Years Ago
  • 0 Lessons Completed
  • 0 Favorites

16th April, 2018

ElijahPaul left a reply on PostgreSQL Connection Via Environment Variables For Local And Production Environments. • 1 week ago

@Cronix I feel stupid for not thinking of that. So simple! Thank you.

ElijahPaul started a new conversation PostgreSQL Connection Via Environment Variables For Local And Production Environments. • 1 week ago

How would i configure the config/database.php file to account for an unsecured local PostgreSQL connection and a secure production one?

My current config:

'pgsql' => [
            'driver' => 'pgsql',
            'host' => env('DB_HOST', 'localhost'),
            'port' => env('DB_PORT', '5432'),
            'database' => env('DB_DATABASE', 'forge'),
            'username' => env('DB_USERNAME', 'forge'),
            'password' => env('DB_PASSWORD', ''),
            'charset' => 'utf8',
            'prefix' => '',
            'schema' => 'public',
            'sslmode' => 'prefer',
        ],

If I add the following to the database.php config file...

.....
'sslcert' => env('DB_SSLCERT', ''),
'sslkey' => env('DB_SSLKEY', ''),
'sslrootcert' => env('DB_SSLROOTCERT', ''),
.....

And set the environment variables (only in production)...

DB_SSLMODE=verify-full
DB_SSLCERT=/path/to/mycert.pem
DB_SSLKEY=/path/to/mykey.pem
DB_SSLROOTCERT=/path/to/myrootcert.pem

The local connection (without adding the corresponding environment variables) fails, but the production environment (with the variables set) connects successfully.

So how should i configure config/database.php to accommodate both local (unsecured) and production (secure) database connection requirements?

12th March, 2018

ElijahPaul started a new conversation Laravel 5.5 - Redis Queue Logs • 1 month ago

Are the Redis (4.0.8) logs below normal behaviour/expected? (My queues are processing normally)

1520861326.143064 [0 lua] "lpop" "queues:default"
1520861329.143602 [0 10.42.197.60:54104] "GET" "app_cache:illuminate:queue:restart"
1520861329.144294 [0 10.42.197.60:54104] "EVAL" "-- Get all of the jobs with an expired \"score\"...\nlocal val = redis.call('zrangebyscore', KEYS[1], '-inf', ARGV[1])\n\n-- If we have values in the array, we will remove them from the first queue\n-- and add them onto the destination queue in chunks of 100, which moves\n-- all of the appropriate jobs onto the destination queue very safely.\nif(next(val) ~= nil) then\n    redis.call('zremrangebyrank', KEYS[1], 0, #val - 1)\n\n    for i = 1, #val, 100 do\n        redis.call('rpush', KEYS[2], unpack(val, i, math.min(i+99, #val)))\n    end\nend\n\nreturn val" "2" "queues:default:delayed" "queues:default" "1520861329"
1520861329.144615 [0 lua] "zrangebyscore" "queues:default:delayed" "-inf" "1520861329"
1520861329.145030 [0 10.42.197.60:54104] "EVAL" "-- Get all of the jobs with an expired \"score\"...\nlocal val = redis.call('zrangebyscore', KEYS[1], '-inf', ARGV[1])\n\n-- If we have values in the array, we will remove them from the first queue\n-- and add them onto the destination queue in chunks of 100, which moves\n-- all of the appropriate jobs onto the destination queue very safely.\nif(next(val) ~= nil) then\n    redis.call('zremrangebyrank', KEYS[1], 0, #val - 1)\n\n    for i = 1, #val, 100 do\n        redis.call('rpush', KEYS[2], unpack(val, i, math.min(i+99, #val)))\n    end\nend\n\nreturn val" "2" "queues:default:reserved" "queues:default" "1520861329"
1520861329.145370 [0 lua] "zrangebyscore" "queues:default:reserved" "-inf" "1520861329"
1520861329.145913 [0 10.42.197.60:54104] "EVAL" "-- Pop the first job off of the queue...\nlocal job = redis.call('lpop', KEYS[1])\nlocal reserved = false\n\nif(job ~= false) then\n    -- Increment the attempt count and place job on the reserved queue...\n    reserved = cjson.decode(job)\n    reserved['attempts'] = reserved['attempts'] + 1\n    reserved = cjson.encode(reserved)\n    redis.call('zadd', KEYS[2], ARGV[1], reserved)\nend\n\nreturn {job, reserved}" "2" "queues:default" "queues:default:reserved" "1520861419"

23rd February, 2018

ElijahPaul left a reply on 'Method WhereBetween Does Not Exist' When Using Cached Query. • 2 months ago

@m-rk yeah, I'm slowly figuring that out.

The DB (postgres) has ≈ 20,000 records at the moment, and all the 'fiddling' I've done so far regarding caching + filtering has negatively impacted performance.

Overall query and filtering performance is actually pretty good as it is. So I may just leave this one alone for now.

Still learning, so I appreciate the input.

ElijahPaul left a reply on 'Method WhereBetween Does Not Exist' When Using Cached Query. • 2 months ago

@m-rk I believe you're right.

I don't think I will end up using this, but still wanted to understand why it wasn't working.

Looking at various ways of reducing DB queries and caching whatever possible (if it improves overall performance and scales of course).

ElijahPaul left a reply on 'Method WhereBetween Does Not Exist' When Using Cached Query. • 2 months ago

@tykus Awesome, thank you.

I need to read up on Collections again, the error seems so obvious now!

ElijahPaul started a new conversation 'Method WhereBetween Does Not Exist' When Using Cached Query. • 2 months ago

Still relatively new to Laravel (5.5) so I think I'm not understanding this correctly.

I'm caching a database query in Redis using the following:

$log = Cache::remember('log'.auth()->id(), 10, function () {
                return log::select(['id', 'clientip', 'token', 'timestamp'])->get();
            });

I want to perform a whereBetween on the cached result and have tried:

$logquery = Cache::get('log'.auth()->id());
$now = Carbon::now();
$to = Carbon::parse($request->get('daterange'));
$logrange = $logquery->whereBetween('timestamp', [$to,$now]);

But this fails with Method whereBetween does not exist in my json response.

What am I doing wrong/not understanding?

Any help appreciated.

31st January, 2018

ElijahPaul left a reply on Duplicate Queries., Different `where` Statements • 2 months ago

@wilburpowery Thanks, will check it out.

ElijahPaul started a new conversation Duplicate Queries., Different `where` Statements • 2 months ago

I'm using clone in the following to perform multiple queries with different where statements.

$query = DB1::whereIn('email',$verified_user_domains);

        $total_clean_count = (clone $query)->where('isspam',false)->count();

        $total_spam_count = (clone $query)->where('isspam',true)->count();

I intend to run a whole bunch of additional where statements and was wondering if there was a more efficient way of achieving this.

Thanks.

Edit Your Profile
Update

Want to change your profile photo? We pull from gravatar.com.