UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = 'T6CW520Q9SGtVz6aqOmlRwnaniMqkMv1lqpUJpVo84M='
WHERE
key_id = 'b66381039e756ddd66dc317c36dba4138242ac72b4f1b6df681b91612c0ed4a5'
AND (
token = 'T6CW520Q9SGtVz6aqOmlRwnaniMqkMv1lqpUJpVo84M='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)