UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'KAM+niqKESdjJu0NKy1Ezos826C98hJYTTtgjhC27MU=' 
WHERE 
  key_id = '338239e4fe69254292b8ed9db127a5e43a6bb00bec80bf2a88b93fe4a7a1a919' 
  AND (
    token = 'KAM+niqKESdjJu0NKy1Ezos826C98hJYTTtgjhC27MU=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00024