UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'wKMPFGz5TB77iE45sbNuWXLTlUTse5pIvIwzx0IhWzM=' 
WHERE 
  key_id = '791dd39b4ed7a19f0dc407b26e99c30b6895714a945578fc8af208265ee58eb5' 
  AND (
    token = 'wKMPFGz5TB77iE45sbNuWXLTlUTse5pIvIwzx0IhWzM=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00042