UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'ygp576VYE5ckNhykFrjT+WyII7zynYrqMi41uG8pdYY=' 
WHERE 
  key_id = '5166634fdf42e2e2d38591299289c9c526aef08c5e340c848e25b64242ab5585' 
  AND (
    token = 'ygp576VYE5ckNhykFrjT+WyII7zynYrqMi41uG8pdYY=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00048