UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'YBsqz0cqRQPtX+9jBmGKHo6X53Kgu41Mgt7d3gFEdhA=' 
WHERE 
  key_id = '9ad20b6049146150a076e6c438cd1df29f97a47e3a046e7733d7b9c1c9e6d803' 
  AND (
    token = 'YBsqz0cqRQPtX+9jBmGKHo6X53Kgu41Mgt7d3gFEdhA=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00024