UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'xl51Wg5VyfVDdIckSmb76AFbpH78ZhWVnTtOeAgjiUs=' 
WHERE 
  key_id = '017d35c2920c343e3d53326ba8c3879d586787e737148fa6bde20f4b3e685c6c' 
  AND (
    token = 'xl51Wg5VyfVDdIckSmb76AFbpH78ZhWVnTtOeAgjiUs=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00029